Skip to content

Commit

Permalink
chore: Remove unneeded importlib_metadata dependency with Python < 3.10
Browse files Browse the repository at this point in the history
It turns out that the `importlib.metadata.distribution()` function is
available in Python 3.8 and 3.9 where it is implemented in
`Lib/importlib/metadata.py` and not `Lib/importlib/metadata/__init__.py`.
  • Loading branch information
jcfr committed Mar 29, 2024
1 parent 80e7b3d commit bdffbdb
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ repos:
args: []
additional_dependencies:
- pytest
# Since the "python_version" set in the "tool.mypy" section of "pyproject.toml" is "3.8",
# we ensure type checking also works when running the hook from Python versions above 3.8 by always
# installing "importlib_metadata". Note that because the "importlib.metadata.distribution"
# module was added in Python version 3.10 and later, this line can be removed when only supporting
# Python versions 3.10 and above.
- importlib_metadata>=2.0

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ classifiers = [
"Typing :: Typed",
]
dynamic = ["version"]
dependencies = ["importlib_metadata>=2.0; python_version<'3.10'"]
dependencies = []

[project.optional-dependencies]
test = [
Expand Down
7 changes: 1 addition & 6 deletions src/idc_index_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@

from __future__ import annotations

import sys
from importlib.metadata import distribution
from pathlib import Path

if sys.version_info >= (3, 10):
from importlib.metadata import distribution
else:
from importlib_metadata import distribution

from ._version import version as __version__

__all__ = [
Expand Down

0 comments on commit bdffbdb

Please sign in to comment.