Skip to content

Commit 5c4e65a

Browse files
committed
fix package metadata for python<3.10
1 parent de82649 commit 5c4e65a

3 files changed

Lines changed: 19 additions & 20 deletions

File tree

pyproject.toml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ classifiers = [
4646
"Typing :: Typed",
4747
]
4848
dependencies = [
49+
"importlib-metadata >= 7.0; python_version < '3.10'",
4950
"sitecustomize-entrypoints >= 1.1.0",
5051
]
5152

@@ -163,12 +164,12 @@ good-names = [
163164

164165
[tool.pylint.messages_control]
165166
disable = [
166-
"C0116", # missing-function-docstring
167+
"C0116", # missing-function-docstring
167168
]
168169

169170
[tool.pytest.ini_options]
170171
cache_dir = "var/cache/pytest"
171-
log_cli = false # enable to show log-output
172+
log_cli = false # enable to show log-output
172173
log_cli_level = "NOTSET"
173174
filterwarnings = []
174175
markers = ["unit", "integration"]
@@ -182,7 +183,7 @@ addopts = "--junit-xml='var/coverage/pytest.xml' --cov --cov-append "
182183
# https://github.com/pandas-dev/pandas/blob/main/pyproject.toml
183184
cache-dir = "var/cache/ruff"
184185
line-length = 120
185-
target-version = "py38"
186+
target-version = "py39"
186187

187188
[tool.ruff.lint]
188189
select = ["ALL"]
@@ -216,14 +217,3 @@ force-single-line = false
216217
[tool.uv]
217218
package = true
218219
default-groups = "all"
219-
# default-groups = [
220-
# "dev",
221-
# "docs",
222-
# "ipython",
223-
# "linting",
224-
# "profiling",
225-
# "releasing",
226-
# "security",
227-
# "testing",
228-
# "typing",
229-
# ]

src/httpclient_logging/about.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,23 @@
77

88
from __future__ import annotations
99

10-
import importlib.metadata
10+
import sys
1111

12-
package: str = __package__ or ""
12+
if sys.version_info >= (3, 10):
13+
import importlib.metadata as importlib_metadata
14+
else:
15+
import importlib_metadata # ty:ignore[unresolved-import]
16+
17+
PACKAGE: str = __package__ or ""
1318

1419

1520
try:
16-
msg = importlib.metadata.metadata(package)
17-
pkginfo: dict[str, str | list[str]] = msg.json # ty: ignore[unresolved-attribute]
21+
msg = importlib_metadata.metadata(PACKAGE)
22+
pkginfo: dict[str, str | list[str]] = msg.json
1823
except ValueError:
1924
# A distribution name is required. __package__ is None
2025
pkginfo = {}
21-
except importlib.metadata.PackageNotFoundError: # pragma: no cover
26+
except importlib_metadata.PackageNotFoundError: # pragma: no cover
2227
# fallback if this package is not properly installed
2328
pkginfo = {}
2429

uv.lock

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)