Skip to content

Commit

Permalink
Merge pull request #460 from materialsproject/importlib-pkg-version
Browse files Browse the repository at this point in the history
Replace deprecated `pkg_resources` with `importlib.metadata.version`
  • Loading branch information
janosh authored Oct 17, 2023
2 parents 231690c + b2cf219 commit fdd1685
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
exclude: "^src/atomate2/vasp/schemas/calc_types/"
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.0
hooks:
- id: ruff
args: [--fix]
Expand All @@ -16,7 +16,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.10.0
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ docs = [
"sphinx==7.2.6",
]
dev = ["pre-commit>=2.12.1"]
tests = ["moto==4.2.5", "pytest-cov==4.1.0", "pytest==7.4.2"]
tests = ["moto==4.2.6", "pytest-cov==4.1.0", "pytest==7.4.2"]
vis = ["matplotlib", "pydot"]
fireworks = ["FireWorks"]
strict = [
Expand Down
6 changes: 3 additions & 3 deletions src/jobflow/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pkg_resources import DistributionNotFound, get_distribution
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = get_distribution("jobflow").version
except DistributionNotFound:
__version__ = version("jobflow")
except PackageNotFoundError:
# package is not installed
__version__ = ""
7 changes: 4 additions & 3 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

import pytest


Expand All @@ -18,11 +20,10 @@ def mock_func(name):
def test_installed_version():
from jobflow import __version__

assert __version__ != ""
assert re.match(r"^\d+\.\d+\.\d+$", __version__)


@pytest.mark.usefixtures("uninstall_jobflow")
def test_not_installed_version(monkeypatch):
def test_not_installed_version(uninstall_jobflow):
import importlib

from jobflow import _version
Expand Down

0 comments on commit fdd1685

Please sign in to comment.