Skip to content

Commit e849ae3

Browse files
Drop Python 3.7 support (#106)
* Drop Python 3.7 support * Update pyproject.toml Co-authored-by: Chris Markiewicz <[email protected]> * Update importlib.metadata import --------- Co-authored-by: Chris Markiewicz <[email protected]>
1 parent 017345f commit e849ae3

File tree

4 files changed

+6
-25
lines changed

4 files changed

+6
-25
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,7 @@ jobs:
99
matrix:
1010
os: [ubuntu, macos, windows]
1111
python-version:
12-
[
13-
"3.7",
14-
"3.8",
15-
"3.9",
16-
"3.10",
17-
"3.11",
18-
"3.12-dev",
19-
"pypy-3.8",
20-
"pypy-3.9",
21-
]
12+
["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.8", "pypy-3.9"]
2213

2314
steps:
2415
- uses: actions/checkout@v4

lazy_loader/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ def attach(package_name, submodules=None, submod_attrs=None):
4343
{'foo': ['someattr']}
4444
)
4545
46-
This functionality requires Python 3.7 or higher.
47-
4846
Parameters
4947
----------
5048
package_name : str
@@ -269,16 +267,13 @@ def _check_requirement(require: str) -> bool:
269267
True if the installed version of the dependency matches
270268
the specified version, False otherwise.
271269
"""
272-
import packaging.requirements
270+
import importlib.metadata
273271

274-
try:
275-
import importlib.metadata as importlib_metadata
276-
except ImportError: # PY37
277-
import importlib_metadata
272+
import packaging.requirements
278273

279274
req = packaging.requirements.Requirement(require)
280275
return req.specifier.contains(
281-
importlib_metadata.version(req.name),
276+
importlib.metadata.version(req.name),
282277
prereleases=True,
283278
)
284279

lazy_loader/tests/test_lazy_loader.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,8 @@ def test_stub_loading_errors(tmp_path):
160160

161161

162162
def test_require_kwarg():
163-
have_importlib_metadata = importlib.util.find_spec("importlib.metadata") is not None
164-
dot = "." if have_importlib_metadata else "_"
165163
# Test with a module that definitely exists, behavior hinges on requirement
166-
with mock.patch(f"importlib{dot}metadata.version") as version:
164+
with mock.patch("importlib.metadata.version") as version:
167165
version.return_value = "1.0.0"
168166
math = lazy.load("math", require="somepkg >= 2.0")
169167
assert isinstance(math, lazy.DelayedImportErrorModule)

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "lazy_loader"
7-
requires-python = ">=3.7"
7+
requires-python = ">=3.8"
88
authors = [{name = "Scientific Python Developers"}]
99
readme = "README.md"
1010
license = {file = "LICENSE.md"}
@@ -13,7 +13,6 @@ classifiers = [
1313
"Development Status :: 4 - Beta",
1414
"License :: OSI Approved :: BSD License",
1515
"Programming Language :: Python :: 3",
16-
"Programming Language :: Python :: 3.7",
1716
"Programming Language :: Python :: 3.8",
1817
"Programming Language :: Python :: 3.9",
1918
"Programming Language :: Python :: 3.10",
@@ -23,7 +22,6 @@ classifiers = [
2322
description = "Makes it easy to load subpackages and functions on demand."
2423
dependencies = [
2524
"packaging",
26-
"importlib_metadata; python_version < '3.8'",
2725
]
2826

2927
[project.optional-dependencies]
@@ -44,7 +42,6 @@ attr = 'lazy_loader.__version__'
4442

4543
[tool.ruff]
4644
line-length = 88
47-
target-version = "py37"
4845
select = [
4946
"C",
5047
"E",

0 commit comments

Comments
 (0)