Skip to content

Commit

Permalink
Pre-commit update + fix docs build (#402)
Browse files Browse the repository at this point in the history
* Update tox.ini
* Add pip to dependencies
* Pin sphinxcontrib packages
* Bump pre-commit version
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
danielhollas committed Feb 23, 2024
1 parent d2ea0ec commit d652291
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 33 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,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
Expand All @@ -23,36 +23,36 @@ 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+

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
args: [--count, --show-source, --statistics]

- 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/sirosen/check-jsonschema
rev: 0.27.0
rev: 0.28.0
hooks:
- id: check-github-workflows

- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.8.0
hooks:
- id: mypy
args: [--config-file=setup.cfg]
Expand Down
42 changes: 26 additions & 16 deletions aiidalab/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,37 @@ def _repo(self) -> Repo | None:
return None

def installed_version(self) -> AppVersion | str:
def get_version_from_metadata() -> AppVersion | str:
version = self.metadata.get("version")
if isinstance(version, str):
return version
else:
return AppVersion.UNKNOWN

if self._repo and self.is_registered():
if self.dirty():
return AppVersion.UNKNOWN

try:
head_commit = self._repo.head().decode()
versions_by_commit = {
split_git_url(release["url"])[1]: version
for version, release in self.releases.items()
if urlsplit(release["url"]).scheme.startswith("git+")
}
# TODO: Use less-broad Exception here!
except Exception as error:
logger.warning(f"Encountered error while determining version: {error}")
return AppVersion.UNKNOWN

version = versions_by_commit.get(head_commit)
if isinstance(version, str):
return version
else:
try:
head_commit = self._repo.head().decode()
versions_by_commit = {
split_git_url(release["url"])[1]: version
for version, release in self.releases.items()
if urlsplit(release["url"]).scheme.startswith("git+")
}
return versions_by_commit.get(
head_commit, self.metadata.get("version", AppVersion.UNKNOWN)
)
except Exception as error:
logger.debug(
f"Encountered error while determining version: {error}"
)
return AppVersion.UNKNOWN
return get_version_from_metadata()

elif self.is_installed():
return self.metadata.get("version", AppVersion.UNKNOWN)
return get_version_from_metadata()

return AppVersion.NOT_INSTALLED

Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
# this version is required to support reading of version in setup.cfg
requires = ["setuptools>=46.4.0"]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
norecursedirs = "tests/data"
15 changes: 13 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ install_requires =
jsonref~=0.2
jsonschema[format]~=3.2
packaging>=20.1,<22
pip
requests~=2.27
requests-cache~=0.5
requests-mock~=1.8
Expand All @@ -51,15 +52,25 @@ console_scripts =
[options.extras_require]
dev =
bumpver==2021.1114
pre-commit==2.11.1
pytest==7.2.1
pre-commit~=3.5
pytest~=7.2.1
pytest-cov~=4.0
docs =
pydata-sphinx-theme~=0.13.3
sphinx~=4.4.0
sphinx-panels~=0.6.0
sphinxcontrib-contentui
sphinxcontrib-details-directive;python_version>='3.0'
# NOTE: These need to be pinned due to incompatibility with sphinx<5.0
# https://github.com/sphinx-doc/sphinx/issues/11890
# We can't easily upgrade to sphinx v5.0 since sphinx-panels is incompatible
# and is deprecated, we'd need to migrate to sphinx-design.
# https://sphinx-design.readthedocs.io/en/latest/get_started.html#migrating-from-sphinx-panels
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5

[flake8]
ignore =
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
# then run `tox` or `tox -- {pytest args}`
# run in parallel using `tox -p`

# see also test/rmq/docker-compose.yml to start a rabbitmq server, required for the those tests

[tox]
envlist = py37
envlist = py39

[testenv]
usedevelop = true

[testenv:py{37,38,39}]
[testenv:py{39,310,311,312}]
description = Run the unit tests
extras =
tests
allowlist_externals =
pytest
commands = pytest {posargs:tests}

[testenv:docs-{update,clean}]
description = Build the documentation
extras =
docs
whitelist_externals =
allowlist_externals =
rm
echo
commands =
Expand Down

0 comments on commit d652291

Please sign in to comment.