Skip to content

Commit 0b1ca1c

Browse files
authored
chore: add ruff PYI (#1026)
1 parent f1dfe82 commit 0b1ca1c

4 files changed

Lines changed: 18 additions & 10 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ extend-select = [
213213
"PIE", # flake8-pie
214214
"PT", # flake8-pytest-style
215215
# "PTH", # flake8-use-pathlib
216-
# "PYI", # flake8-pyi
216+
"PYI", # flake8-pyi
217217
# "RET", # flake8-return
218218
"RSE", # flake8-raise
219219
# "SIM", # flake8-simplify

src/build/_builder.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import warnings
2626
import zipfile
2727

28-
from typing import Any, TypeVar
28+
from typing import Any
2929

3030
import pyproject_hooks
3131

@@ -45,10 +45,12 @@
4545
if TYPE_CHECKING:
4646
from collections.abc import Iterator, Mapping, Sequence
4747

48-
from ._types import ConfigSettings, Distribution, StrPath, SubprocessRunner
49-
48+
if sys.version_info < (3, 11):
49+
from typing_extensions import Self
50+
else:
51+
from typing import Self
5052

51-
_TProjectBuilder = TypeVar('_TProjectBuilder', bound='ProjectBuilder')
53+
from ._types import ConfigSettings, Distribution, StrPath, SubprocessRunner
5254

5355

5456
_DEFAULT_BACKEND = {
@@ -205,11 +207,11 @@ def __init__(
205207

206208
@classmethod
207209
def from_isolated_env(
208-
cls: type[_TProjectBuilder],
210+
cls,
209211
env: env.IsolatedEnv,
210212
source_dir: StrPath,
211213
runner: SubprocessRunner = pyproject_hooks.default_subprocess_runner,
212-
) -> _TProjectBuilder:
214+
) -> Self:
213215
return cls(
214216
source_dir=source_dir,
215217
python_executable=env.python_executable,

src/build/_util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
TYPE_CHECKING = False
77

88
if TYPE_CHECKING:
9-
from collections.abc import Iterator, Set
9+
from collections.abc import Iterator
10+
from collections.abc import Set as AbstractSet
1011

1112

1213
_WHEEL_FILENAME_REGEX = re.compile(
@@ -17,7 +18,7 @@
1718

1819

1920
def check_dependency(
20-
req_string: str, ancestral_req_strings: tuple[str, ...] = (), parent_extras: Set[str] = frozenset()
21+
req_string: str, ancestral_req_strings: tuple[str, ...] = (), parent_extras: AbstractSet[str] = frozenset()
2122
) -> Iterator[tuple[str, ...]]:
2223
"""
2324
Verify that a dependency and all of its dependencies are met.

src/build/env.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646

4747
from ._compat.importlib import metadata as importlib_metadata
4848

49+
if sys.version_info < (3, 11):
50+
from typing_extensions import Self
51+
else:
52+
from typing import Self
53+
4954

5055
Installer = typing.Literal['pip', 'uv']
5156

@@ -103,7 +108,7 @@ def __init__(
103108
) -> None:
104109
self.installer: Installer = installer
105110

106-
def __enter__(self) -> DefaultIsolatedEnv:
111+
def __enter__(self) -> Self:
107112
try:
108113
path = tempfile.mkdtemp(prefix='build-env-')
109114
# Call ``realpath`` to prevent spurious warning from being emitted

0 commit comments

Comments
 (0)