From bdffbdbdc3d3992b949d22f92aba768104b1d463 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Fri, 29 Mar 2024 17:00:19 -0400 Subject: [PATCH] chore: Remove unneeded importlib_metadata dependency with Python < 3.10 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`. --- .pre-commit-config.yaml | 6 ------ pyproject.toml | 2 +- src/idc_index_data/__init__.py | 7 +------ 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ddd1ab1..bb59985 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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" diff --git a/pyproject.toml b/pyproject.toml index 1b72392..2737df0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ classifiers = [ "Typing :: Typed", ] dynamic = ["version"] -dependencies = ["importlib_metadata>=2.0; python_version<'3.10'"] +dependencies = [] [project.optional-dependencies] test = [ diff --git a/src/idc_index_data/__init__.py b/src/idc_index_data/__init__.py index 80c2097..217cd24 100644 --- a/src/idc_index_data/__init__.py +++ b/src/idc_index_data/__init__.py @@ -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__ = [