Skip to content

Commit ca6ab7c

Browse files
committed
py: drop Python 3.9
Signed-off-by: Filipe Laíns <[email protected]>
1 parent 4e7bc33 commit ca6ab7c

File tree

5 files changed

+18
-29
lines changed

5 files changed

+18
-29
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@ jobs:
2424
- windows-11-arm
2525
- macos-latest
2626
python:
27-
- '3.9'
2827
- '3.10'
2928
- '3.11'
3029
- '3.12'
3130
- '3.13'
3231
exclude:
33-
- os: windows-11-arm
34-
python: '3.9'
3532
- os: windows-11-arm
3633
python: '3.10'
3734
fail-fast: false

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ classifiers = [
3131
'Operating System :: Unix',
3232
'Operating System :: MacOS'
3333
]
34-
requires-python = '>= 3.9'
34+
requires-python = '>= 3.10'
3535
dependencies = [
3636
'colorama; os_name == "nt"',
37-
'importlib_metadata; python_version < "3.10"',
38-
'importlib_resources; python_version < "3.10"',
3937
]
4038

4139
[project.optional-dependencies]

src/pkgconf/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sysconfig
88
import warnings
99

10-
from typing import Any, Optional, Union
10+
from typing import Any
1111

1212
import pkgconf._path_entrypoints
1313

@@ -21,7 +21,7 @@
2121
_CLI_LOGGER = _LOGGER.getChild('cli')
2222

2323

24-
def _get_system_executable() -> Optional[pathlib.Path]:
24+
def _get_system_executable() -> pathlib.Path | None:
2525
if os.environ.get('PKGCONF_PYPI_EMBEDDED_ONLY'):
2626
return None
2727

@@ -39,7 +39,7 @@ def _get_system_executable() -> Optional[pathlib.Path]:
3939

4040
def get_executable() -> pathlib.Path:
4141
"""Get the pkgconf executable."""
42-
executable: Optional[pathlib.Path]
42+
executable: pathlib.Path | None
4343

4444
if os.name == 'posix':
4545
executable_name = 'pkgconf'
@@ -79,7 +79,7 @@ def get_pkg_config_path() -> list[str]:
7979
return [ep.path for ep in _entry_points()]
8080

8181

82-
def run_pkgconf(*args: str, **subprocess_kwargs: Any) -> subprocess.CompletedProcess[Union[bytes, str]]:
82+
def run_pkgconf(*args: str, **subprocess_kwargs: Any) -> subprocess.CompletedProcess[bytes | str]:
8383
"""Run the pkgconf executable.
8484
8585
:param args: Arguments to pass to the pkgconf call.

src/pkgconf/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sysconfig
77
import warnings
88

9-
from typing import Optional, TextIO, Union
9+
from typing import TextIO
1010

1111
import pkgconf
1212

@@ -104,12 +104,12 @@ def _setup_cli():
104104
pkgconf._CLI_LOGGER.setLevel(logging.INFO)
105105

106106
def _showwarning(
107-
message: Union[Warning, str],
107+
message: Warning | str,
108108
category: type[Warning],
109109
filename: str,
110110
lineno: int,
111-
file: Optional[TextIO] = None,
112-
line: Optional[str] = None,
111+
file: TextIO | None = None,
112+
line: str | None = None,
113113
) -> None: # pragma: no cover
114114
print(f'{yellow}WARNING{reset} {message}', file=sys.stderr)
115115

src/pkgconf/_path_entrypoints.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import contextlib
22
import importlib.machinery
3+
import importlib.metadata
4+
import importlib.resources
35
import importlib.util
46
import operator
57
import os
@@ -10,20 +12,12 @@
1012
import types
1113
import warnings
1214

13-
from collections.abc import Iterable
14-
from typing import Any, Callable, Optional, ParamSpec, TypeVar
15+
from collections.abc import Callable, Iterable
16+
from typing import Any, ParamSpec, TypeVar
1517

1618
import pkgconf
1719

1820

19-
if sys.version_info >= (3, 10):
20-
import importlib.metadata as importlib_metadata
21-
import importlib.resources as importlib_resources
22-
else:
23-
import importlib_metadata
24-
import importlib_resources
25-
26-
2721
P = ParamSpec('P')
2822
T = TypeVar('T')
2923

@@ -63,7 +57,7 @@ def module_path(name: str) -> str:
6357
if len(module.__spec__.submodule_search_locations) == 1:
6458
return module.__spec__.submodule_search_locations[0]
6559
# Traversables often implement __fspath__, attempt to use it.
66-
traversable = importlib_resources.files(module)
60+
traversable = importlib.resources.files(module)
6761
if isinstance(traversable, os.PathLike):
6862
return os.fsdecode(os.fspath(traversable))
6963
# Give up :/
@@ -129,7 +123,7 @@ def replace_sys_modules() -> Iterable[None]:
129123

130124

131125
class EntryPoint:
132-
def __init__(self, entrypoint: importlib_metadata.EntryPoint) -> None:
126+
def __init__(self, entrypoint: importlib.metadata.EntryPoint) -> None:
133127
self._ep = entrypoint
134128

135129
@property
@@ -145,7 +139,7 @@ def group(self) -> str:
145139
return self._ep.group
146140

147141
@property
148-
def dist(self) -> Optional[importlib_metadata.Distribution]:
142+
def dist(self) -> importlib.metadata.Distribution | None:
149143
return self._ep.dist
150144

151145
@property
@@ -180,7 +174,7 @@ def _resolve_via_translation(self) -> str:
180174

181175

182176
def entry_points(**select_params: Any) -> list[EntryPoint]:
183-
original_eps = importlib_metadata.entry_points(**select_params)
177+
original_eps = importlib.metadata.entry_points(**select_params)
184178
our_eps = map(EntryPoint, original_eps)
185179
valid_eps = filter(operator.attrgetter('path'), our_eps)
186180
return sorted(valid_eps, key=operator.attrgetter('name'))
@@ -206,7 +200,7 @@ def _distribution_info(self) -> str:
206200
info += f' at {metadata_path!r}'
207201
return info
208202

209-
def _find_metadata_path(self) -> Optional[str]:
203+
def _find_metadata_path(self) -> str | None:
210204
assert self._entrypoint.dist
211205
try:
212206
dist_root = self._entrypoint.dist.locate_file('')

0 commit comments

Comments
 (0)