From 0f6e61a1bb5eee331051430cf034b8f99294de23 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 26 Jul 2023 13:45:02 +0100 Subject: [PATCH 01/10] Disable prompt for appstore and single app page (#154) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a follow up on #141 where we disabled the alert prompt when leaving the home page. We've been using it for quite a while since and haven't noticed any issues so it's time to apply to other apps / pages. In the future, we should ideally apply this fix directly in Appmode, but that will require more work so for now here's just a simple hotfix. --- appstore.ipynb | 3 +++ single_app.ipynb | 3 +++ 2 files changed, 6 insertions(+) diff --git a/appstore.ipynb b/appstore.ipynb index 10b15c9..e478093 100644 --- a/appstore.ipynb +++ b/appstore.ipynb @@ -19,6 +19,9 @@ "%%javascript\n", "IPython.OutputArea.prototype._should_scroll = function(lines) {\n", " return false;\n", + "}\n", + "if (document.getElementById('appmode-busy')) {\n", + " window.onbeforeunload = function() {return}\n", "}" ] }, diff --git a/single_app.ipynb b/single_app.ipynb index 7f5868b..31cb51b 100644 --- a/single_app.ipynb +++ b/single_app.ipynb @@ -9,6 +9,9 @@ "%%javascript\n", "IPython.OutputArea.prototype._should_scroll = function(lines) {\n", " return false;\n", + "}\n", + "if (document.getElementById('appmode-busy')) {\n", + " window.onbeforeunload = function() {return}\n", "}" ] }, From 2ad52ab80429550b13e157a359771610d84708d2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 17:57:18 +0200 Subject: [PATCH 02/10] [pre-commit.ci] pre-commit autoupdate (#157) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.3.0 → 23.9.1](https://github.com/psf/black/compare/23.3.0...23.9.1) - [github.com/PyCQA/flake8: 6.0.0 → 6.1.0](https://github.com/PyCQA/flake8/compare/6.0.0...6.1.0) - [github.com/sirosen/check-jsonschema: 0.23.2 → 0.27.0](https://github.com/sirosen/check-jsonschema/compare/0.23.2...0.27.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb4d053..9a6f8a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,13 +19,13 @@ repos: - id: yamlfmt - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.9.1 hooks: - id: black language_version: python3 # Should be a command that runs python3.6+ - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 args: [--count, --show-source, --statistics] @@ -44,7 +44,7 @@ repos: - id: setup-cfg-fmt - repo: https://github.com/sirosen/check-jsonschema - rev: 0.23.2 + rev: 0.27.0 hooks: - id: check-github-workflows From 4f3036ce1b2ebfcd5de131da49df3d06220d01b6 Mon Sep 17 00:00:00 2001 From: Aliaksandr Yakutovich Date: Fri, 5 Jan 2024 09:55:26 +0100 Subject: [PATCH 03/10] VersionSelectorWidget: fix start-unpacking complaint from `flake8` (#159) --- home/app_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/app_manager.py b/home/app_manager.py index 1577306..b6c9f6c 100644 --- a/home/app_manager.py +++ b/home/app_manager.py @@ -69,9 +69,9 @@ def __init__(self, *args, **kwargs): ) super().__init__( + *args, children=[self.installed_version, self.version_to_install, self.info], layout={"min_width": "300px"}, - *args, **kwargs, ) From fc0af70ab61b5fc16650b2f1ff41c0a07c7eab81 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jan 2024 10:27:45 +0100 Subject: [PATCH 04/10] [pre-commit.ci] pre-commit autoupdate (#158) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) - [github.com/psf/black: 23.9.1 → 23.12.1](https://github.com/psf/black/compare/23.9.1...23.12.1) - [github.com/pycqa/isort: 5.12.0 → 5.13.2](https://github.com/pycqa/isort/compare/5.12.0...5.13.2) - [github.com/asottile/setup-cfg-fmt: v2.4.0 → v2.5.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.4.0...v2.5.0) - [github.com/sirosen/check-jsonschema: 0.27.0 → 0.27.3](https://github.com/sirosen/check-jsonschema/compare/0.27.0...0.27.3) * Update pre-commit version * Update Python * typo --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Aliaksandr Yakutovich --- .github/workflows/ci.yml | 2 +- .pre-commit-config.yaml | 10 +++++----- setup.cfg | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 316bc70..968c8e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.11 - name: Install dependencies run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9a6f8a5..0c348c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-json - id: check-yaml @@ -19,7 +19,7 @@ repos: - id: yamlfmt - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.12.1 hooks: - id: black language_version: python3 # Should be a command that runs python3.6+ @@ -33,18 +33,18 @@ repos: - flake8-bugbear - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort args: [--profile, black, --filter-files] - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.4.0 + rev: v2.5.0 hooks: - id: setup-cfg-fmt - repo: https://github.com/sirosen/check-jsonschema - rev: 0.27.0 + rev: 0.27.3 hooks: - id: check-github-workflows diff --git a/setup.cfg b/setup.cfg index 3744fda..36a6738 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,12 +28,12 @@ install_requires = ipywidgets~=7.6 traitlets~=5.0 widgetsnbextension<3.6.3 # Hotfix. Remove when #149 is fixed -python_requires = >=3.8 +python_requires = >=3.9 [options.extras_require] dev = bumpver==2022.1118 - pre-commit==2.15.0 + pre-commit==3.6.0 [flake8] ignore = From 45d88be7fe48e14e69683632fcc063601417bbc3 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 27 Feb 2024 07:37:14 +0000 Subject: [PATCH 05/10] Add Dependabot config for updating GHAs (#160) --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..23a311e --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +--- +version: 2 +updates: +# Maintain dependencies for GitHub Actions + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily + groups: + gha-dependencies: + patterns: + - '*' From ff8a7f6b3fdaf208dfd45041b21de01cddc1c9a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 09:16:14 +0100 Subject: [PATCH 06/10] Bump the gha-dependencies group with 3 updates (#162) Bumps the gha-dependencies group with 3 updates: [actions/checkout](https://github.com/actions/checkout), [actions/setup-python](https://github.com/actions/setup-python) and [softprops/action-gh-release](https://github.com/softprops/action-gh-release). Updates `actions/checkout` from 2 to 4 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v4) Updates `actions/setup-python` from 2 to 5 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v2...v5) Updates `softprops/action-gh-release` from 0.1.14 to 0.1.15 - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v0.1.14...v0.1.15) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major dependency-group: gha-dependencies - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major dependency-group: gha-dependencies - dependency-name: softprops/action-gh-release dependency-type: direct:production update-type: version-update:semver-patch dependency-group: gha-dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++-- .github/workflows/release.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 968c8e1..297a9ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.11 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ae09e4f..116f5d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: softprops/action-gh-release@v0.1.14 + - uses: softprops/action-gh-release@v0.1.15 name: Create release. with: generate_release_notes: true From f41169fce150c9bed8cdf105a4117d4371ff8506 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:26:54 +0600 Subject: [PATCH 07/10] Bump the gha-dependencies group with 1 update (#164) Bumps the gha-dependencies group with 1 update: [softprops/action-gh-release](https://github.com/softprops/action-gh-release). Updates `softprops/action-gh-release` from 0.1.15 to 2.0.4 - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v0.1.15...v2.0.4) --- updated-dependencies: - dependency-name: softprops/action-gh-release dependency-type: direct:production update-type: version-update:semver-major dependency-group: gha-dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 116f5d6..9f036ef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: softprops/action-gh-release@v0.1.15 + - uses: softprops/action-gh-release@v2.0.4 name: Create release. with: generate_release_notes: true From f51088eeef77bf1a9ba50a2c41586bc61e4acd5b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:31:48 +0200 Subject: [PATCH 08/10] [pre-commit.ci] pre-commit autoupdate (#165) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 23.12.1 → 24.3.0](https://github.com/psf/black/compare/23.12.1...24.3.0) - [github.com/PyCQA/flake8: 6.1.0 → 7.0.0](https://github.com/PyCQA/flake8/compare/6.1.0...7.0.0) - [github.com/sirosen/check-jsonschema: 0.27.3 → 0.28.1](https://github.com/sirosen/check-jsonschema/compare/0.27.3...0.28.1) - [github.com/kynan/nbstripout: 0.6.1 → 0.7.1](https://github.com/kynan/nbstripout/compare/0.6.1...0.7.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 8 ++++---- home/app_manager.py | 24 ++++++------------------ home/start_page.py | 1 + open_app.ipynb | 8 ++++---- 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c348c4..473a502 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,13 +19,13 @@ repos: - id: yamlfmt - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.3.0 hooks: - id: black language_version: python3 # Should be a command that runs python3.6+ - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 args: [--count, --show-source, --statistics] @@ -44,11 +44,11 @@ repos: - id: setup-cfg-fmt - repo: https://github.com/sirosen/check-jsonschema - rev: 0.27.3 + rev: 0.28.1 hooks: - id: check-github-workflows - repo: https://github.com/kynan/nbstripout - rev: 0.6.1 + rev: 0.7.1 hooks: - id: nbstripout diff --git a/home/app_manager.py b/home/app_manager.py index b6c9f6c..31c805e 100644 --- a/home/app_manager.py +++ b/home/app_manager.py @@ -347,25 +347,19 @@ def _refresh_widget_state(self, _=None): self.install_button.icon = ( "" if can_install and not detached - else warn_or_ban_icon - if can_install - else "" + else warn_or_ban_icon if can_install else "" ) if self.app.compatible: self.install_button.tooltip = ( "" if can_install and not detached - else tooltip_danger - if can_install - else "" + else tooltip_danger if can_install else "" ) else: self.install_button.tooltip = ( "" if installed and not detached - else tooltip_danger - if installed - else tooltip_incompatible + else tooltip_danger if installed else tooltip_incompatible ) self.install_button.description = ( "Install" @@ -382,9 +376,7 @@ def _refresh_widget_state(self, _=None): self.uninstall_button.tooltip = ( "" if can_uninstall and not detached - else tooltip_danger - if can_uninstall - else "" + else tooltip_danger if can_uninstall else "" ) # Update the update button state. @@ -398,17 +390,13 @@ def _refresh_widget_state(self, _=None): self.update_button.icon = ( "arrow-circle-up" if can_update and not detached - else warn_or_ban_icon - if can_update - else "" + else warn_or_ban_icon if can_update else "" ) self.update_button.button_style = "success" if can_update else "" self.update_button.tooltip = ( "" if can_update and not detached - else tooltip_danger - if can_update - else "" + else tooltip_danger if can_update else "" ) # Update the version_selector widget state. diff --git a/home/start_page.py b/home/start_page.py index d6a10bb..a384b77 100644 --- a/home/start_page.py +++ b/home/start_page.py @@ -1,4 +1,5 @@ """Module to generate AiiDAlab home page.""" + import json from functools import wraps from glob import glob diff --git a/open_app.ipynb b/open_app.ipynb index 8f23ee0..11dde5d 100644 --- a/open_app.ipynb +++ b/open_app.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1e6a8c8c", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -14,7 +14,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7e7e205e", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b3e749de", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c25a71a5", + "id": "3", "metadata": {}, "outputs": [], "source": [ From a2a6c5f15d6991772bef8fb9dfaabd199fab3402 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 09:49:08 +0200 Subject: [PATCH 09/10] Bump softprops/action-gh-release in the gha-dependencies group (#167) Bumps the gha-dependencies group with 1 update: [softprops/action-gh-release](https://github.com/softprops/action-gh-release). Updates `softprops/action-gh-release` from 2.0.4 to 2.0.5 - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v2.0.4...v2.0.5) --- updated-dependencies: - dependency-name: softprops/action-gh-release dependency-type: direct:production update-type: version-update:semver-patch dependency-group: gha-dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f036ef..5906064 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: softprops/action-gh-release@v2.0.4 + - uses: softprops/action-gh-release@v2.0.5 name: Create release. with: generate_release_notes: true From eddcf1078d73d6b477eabc88bf895c88ab5b6fa6 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Wed, 15 May 2024 01:22:47 +0100 Subject: [PATCH 10/10] User ruff linter and formatter (#166) --- .github/dependabot.yml | 2 +- .pre-commit-config.yaml | 28 ++++++++-------------------- home/app_manager.py | 28 ++++++++++++++++++++-------- home/app_store.py | 12 ++++-------- home/start_page.py | 6 +++--- home/utils.py | 6 +++--- home/widgets.py | 3 +-- pyproject.toml | 31 +++++++++++++++++++++++++++++++ setup.py | 2 +- 9 files changed, 72 insertions(+), 46 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 23a311e..ce0d77c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ updates: - package-ecosystem: github-actions directory: / schedule: - interval: daily + interval: monthly groups: gha-dependencies: patterns: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 473a502..1938ed9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,31 +13,19 @@ repos: - id: trailing-whitespace exclude: miscellaneous/structures/SiO2.xyz + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.5 + hooks: + - id: ruff-format + exclude: ^docs/.* + - id: ruff + args: [--fix, --exit-non-zero-on-fix, --show-fixes] + - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt rev: 0.2.3 hooks: - id: yamlfmt - - repo: https://github.com/psf/black - rev: 24.3.0 - hooks: - - id: black - language_version: python3 # Should be a command that runs python3.6+ - - - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 - hooks: - - id: flake8 - args: [--count, --show-source, --statistics] - additional_dependencies: - - flake8-bugbear - - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - args: [--profile, black, --filter-files] - - repo: https://github.com/asottile/setup-cfg-fmt rev: v2.5.0 hooks: diff --git a/home/app_manager.py b/home/app_manager.py index 31c805e..a18b9e7 100644 --- a/home/app_manager.py +++ b/home/app_manager.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- """Module that contains widgets for managing AiiDAlab applications.""" + from subprocess import CalledProcessError import ipywidgets as ipw @@ -207,7 +207,7 @@ def __init__(self, app, minimalistic=False): self.app.observe( self._refresh_prereleases, names=["has_prereleases", "installed_version"] ) - self._refresh_prereleases(change=dict(owner=self.app)) # initialize + self._refresh_prereleases(change={"owner": self.app}) # initialize children = [ ipw.HBox([self.header_warning]), @@ -347,19 +347,25 @@ def _refresh_widget_state(self, _=None): self.install_button.icon = ( "" if can_install and not detached - else warn_or_ban_icon if can_install else "" + else warn_or_ban_icon + if can_install + else "" ) if self.app.compatible: self.install_button.tooltip = ( "" if can_install and not detached - else tooltip_danger if can_install else "" + else tooltip_danger + if can_install + else "" ) else: self.install_button.tooltip = ( "" if installed and not detached - else tooltip_danger if installed else tooltip_incompatible + else tooltip_danger + if installed + else tooltip_incompatible ) self.install_button.description = ( "Install" @@ -376,7 +382,9 @@ def _refresh_widget_state(self, _=None): self.uninstall_button.tooltip = ( "" if can_uninstall and not detached - else tooltip_danger if can_uninstall else "" + else tooltip_danger + if can_uninstall + else "" ) # Update the update button state. @@ -390,13 +398,17 @@ def _refresh_widget_state(self, _=None): self.update_button.icon = ( "arrow-circle-up" if can_update and not detached - else warn_or_ban_icon if can_update else "" + else warn_or_ban_icon + if can_update + else "" ) self.update_button.button_style = "success" if can_update else "" self.update_button.tooltip = ( "" if can_update and not detached - else tooltip_danger if can_update else "" + else tooltip_danger + if can_update + else "" ) # Update the version_selector widget state. diff --git a/home/app_store.py b/home/app_store.py index f159f3f..e040229 100644 --- a/home/app_store.py +++ b/home/app_store.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- """AiiDAlab app store.""" + import logging import ipywidgets as ipw @@ -21,7 +21,7 @@ def __init__(self): self.index = load_app_registry_index() except RuntimeError as error: logger.warning(error) - self.index = dict(apps=[], categories=[]) + self.index = {"apps": [], "categories": []} self.output = ipw.Output() # Apps per page. @@ -120,12 +120,8 @@ def change_vis_list(self, _=None): if self.category_filter.value: all_apps = self.apps_to_display - self.apps_to_display = ( - [] - ) # clear the array that contains all the apps to be displayed - self.app_corresponding_categories = ( - [] - ) # create a parallel array that contains corresponding category names + self.apps_to_display = [] # clear the array that contains all the apps to be displayed + self.app_corresponding_categories = [] # create a parallel array that contains corresponding category names # iterate over all categories for category in self.category_filter.value: category_key = self.category_title_key_mapping[category] diff --git a/home/start_page.py b/home/start_page.py index a384b77..f67d126 100644 --- a/home/start_page.py +++ b/home/start_page.py @@ -61,7 +61,7 @@ class AiidaLabHome: def __init__(self): self.config_fn = ".launcher.json" self.output = ipw.Output() - self._app_widgets = dict() + self._app_widgets = {} def _create_app_widget(self, name): """Create the widget representing the app on the home screen.""" @@ -93,7 +93,7 @@ def write_config(self, config): def read_config(self): if path.exists(self.config_fn): - return json.load(open(self.config_fn, "r")) + return json.load(open(self.config_fn)) return {"order": [], "hidden": []} # default config def render(self): @@ -125,7 +125,7 @@ def load_apps(self): apps.sort(key=lambda x: order.index(x) if x in order else -1) config["order"] = apps self.write_config(config) - return ["home"] + apps + return ["home", *apps] def move_updown(self, name, delta): """Move the app up/down on the start page.""" diff --git a/home/utils.py b/home/utils.py index 71ca51d..6bdfe49 100644 --- a/home/utils.py +++ b/home/utils.py @@ -33,7 +33,7 @@ def load_start_py(name): except TypeError: return mod.get_start_widget(appbase=appbase, jupbase=jupbase) except Exception: # pylint: disable=broad-except - return ipw.HTML("
{}
".format(sys.exc_info())) + return ipw.HTML(f"
{sys.exc_info()}
") def load_start_md(name): @@ -41,7 +41,7 @@ def load_start_md(name): fname = path.join(AIIDALAB_APPS, name, "start.md") try: md_src = open(fname).read() - md_src = md_src.replace("](./", "](../{}/".format(name)) + md_src = md_src.replace("](./", f"](../{name}/") html = markdown(md_src) # open links in new window/tab @@ -52,7 +52,7 @@ def load_start_md(name): return ipw.HTML(html) except Exception as exc: # pylint: disable=broad-except - return ipw.HTML("Could not load start.md: {}".format(str(exc))) + return ipw.HTML(f"Could not load start.md: {exc!s}") def load_logo(app): diff --git a/home/widgets.py b/home/widgets.py index a0ac4cc..64dd0f9 100644 --- a/home/widgets.py +++ b/home/widgets.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """AiiDAlab basic widgets.""" from threading import Timer @@ -104,7 +103,7 @@ class AppStatusInfoWidget(ipw.HTML): "and avoid compatibility isssues." ) - MESSAGES_UPDATES = { + MESSAGES_UPDATES = { # noqa: RUF012 AppStatus.CANNOT_REACH_REGISTRY: f'
' f'{Theme.ICONS.APP_UPDATE_AVAILABLE_UNKNOWN} ' "Cannot reach server.
", diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b3563e9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,31 @@ +[build-system] +# this version is required to support reading of version in setup.cfg +requires = ["setuptools>=46.4.0"] +build-backend = "setuptools.build_meta" + +[tool.ruff] +line-length = 88 +show-fixes = true +target-version = "py38" + +[tool.ruff.lint] +ignore = ["E501", "E402", "B904", "TRY003"] +select = [ + "A", # flake8-builtins + "ARG", # flake8-unused-arguments + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "E", # pycodestyle + "F", # pyflakes + "I", # isort + "N", # pep8-naming + "PLE", # pylint error rules + "PLW", # pylint warning rules + "PLC", # pylint convention rules + "RUF", # ruff-specific rules + "TRY", # Tryceratops + "UP" # pyupgrade +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["ARG001"] diff --git a/setup.py b/setup.py index 59b746b..63e14cb 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ -# -*- coding: utf8 -*- """This file is required for editable installs of the package.""" + from setuptools import setup setup()