Skip to content

Commit 1250ed4

Browse files
kloczekhenryiii
authored andcommitted
drop python<=3.7 support
According to https://endoflife.date/python python 3.7 has been EOSed 27 Jun 2023. Filter all code over `pyupgrade --py38-plus`. Signed-off-by: Tomasz Kłoczko <[email protected]>
1 parent c3348bf commit 1250ed4

File tree

6 files changed

+15
-40
lines changed

6 files changed

+15
-40
lines changed

src/scikit_build_core/_compat/importlib/metadata.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
from __future__ import annotations
22

3+
import importlib.metadata as _metadata
34
import sys
45
import typing
5-
6-
if sys.version_info < (3, 8):
7-
import importlib_metadata as _metadata
8-
from importlib_metadata import PathDistribution, version
9-
else:
10-
import importlib.metadata as _metadata
11-
from importlib.metadata import PathDistribution, version
12-
6+
from importlib.metadata import PathDistribution, version
137

148
if typing.TYPE_CHECKING:
159
if sys.version_info < (3, 8):

src/scikit_build_core/_compat/typing.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22

33
import sys
44
import typing
5-
6-
if sys.version_info < (3, 8):
7-
from typing_extensions import (
8-
Literal,
9-
Protocol,
10-
)
11-
else:
12-
from typing import Literal, Protocol
5+
from typing import Literal, Protocol
136

147
if sys.version_info < (3, 9):
158
from typing_extensions import Annotated, get_args, get_origin

src/scikit_build_core/_logging.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ def __repr__(self) -> str:
7777
)
7878

7979

80-
if sys.version_info < (3, 8):
81-
opts: Any = {}
82-
else:
83-
opts: Any = {"stacklevel": 2}
80+
opts: Any = {"stacklevel": 2}
8481

8582

8683
class ScikitBuildLogger:

tests/conftest.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@
88
import subprocess
99
import sys
1010
import sysconfig
11+
from importlib import metadata
1112
from pathlib import Path
12-
from typing import Any
13+
from typing import Any, Literal, overload
1314

1415
import virtualenv as _virtualenv
1516

16-
if sys.version_info < (3, 8):
17-
import importlib_metadata as metadata
18-
from typing_extensions import Literal, overload
19-
else:
20-
from importlib import metadata
21-
from typing import Literal, overload
22-
2317
if sys.version_info < (3, 11):
2418
import tomli as tomllib
2519
else:

tests/test_custom_modules.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ def test_ep(isolated):
2323
contents = Path(script).read_text(encoding="utf-8")
2424
assert contents.startswith(f"#!{pysys}")
2525

26-
if sys.version_info >= (3, 8):
27-
assert (
28-
isolated.execute(
29-
"from importlib import metadata; print(metadata.version('custom_modules'), end='')"
30-
)
31-
== "2.3.4"
26+
assert (
27+
isolated.execute(
28+
"from importlib import metadata; print(metadata.version('custom_modules'), end='')"
3229
)
30+
== "2.3.4"
31+
)

tests/test_dynamic_metadata.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import importlib
44
import shutil
55
import subprocess
6-
import sys
76
import textwrap
87
import types
98
import zipfile
@@ -239,11 +238,10 @@ def test_pep517_wheel(virtualenv):
239238
assert wheel == dist / out
240239

241240
virtualenv.install(wheel)
242-
if sys.version_info >= (3, 8):
243-
license = virtualenv.execute(
244-
"from importlib.metadata import metadata; print(metadata('dynamic')['License'])"
245-
)
246-
assert license == "MIT License"
241+
license = virtualenv.execute(
242+
"from importlib.metadata import metadata; print(metadata('dynamic')['License'])"
243+
)
244+
assert license == "MIT License"
247245

248246
with zipfile.ZipFile(wheel) as zf:
249247
file_paths = {Path(n) for n in zf.namelist()}

0 commit comments

Comments
 (0)