Skip to content

Commit 4a71a8d

Browse files
authored
Cleanup, linting, typing (#9839)
1 parent 341071a commit 4a71a8d

File tree

39 files changed

+53
-1342
lines changed

39 files changed

+53
-1342
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
- id: validate_manifest
2828

2929
- repo: https://github.com/astral-sh/ruff-pre-commit
30-
rev: v0.5.4
30+
rev: v0.7.3
3131
hooks:
3232
- id: ruff
3333
- id: ruff-format

poetry.lock

Lines changed: 36 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ extend-exclude = [
9898
# External to the project's coding standards
9999
"tests/fixtures/git/*",
100100
"tests/fixtures/project_with_setup*/*",
101-
"tests/masonry/builders/fixtures/pep_561_stub_only*/*",
102-
"tests/utils/fixtures/setups/*",
103101
]
104102
fix = true
105103
line-length = 88

src/poetry/console/application.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from cleo.events.event_dispatcher import EventDispatcher
1717
from cleo.exceptions import CleoError
1818
from cleo.formatters.style import Style
19-
from cleo.io.null_io import NullIO
2019

2120
from poetry.__version__ import __version__
2221
from poetry.console.command_loader import CommandLoader
@@ -322,13 +321,10 @@ def configure_installer_for_command(command: InstallerCommand, io: IO) -> None:
322321
)
323322
command.set_installer(installer)
324323

325-
def _load_plugins(self, io: IO | None = None) -> None:
324+
def _load_plugins(self, io: IO) -> None:
326325
if self._plugins_loaded:
327326
return
328327

329-
if io is None:
330-
io = NullIO()
331-
332328
self._disable_plugins = io.input.has_parameter_option("--no-plugins")
333329

334330
if not self._disable_plugins:

src/poetry/inspection/lazy_wheel.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
from bisect import bisect_right
1111
from contextlib import contextmanager
1212
from tempfile import NamedTemporaryFile
13+
from typing import IO
1314
from typing import TYPE_CHECKING
1415
from typing import Any
15-
from typing import BinaryIO
1616
from typing import ClassVar
17-
from typing import cast
1817
from urllib.parse import urlparse
1918
from zipfile import BadZipFile
2019
from zipfile import ZipFile
@@ -168,14 +167,14 @@ def minimal_intervals_covering(
168167
yield from self._merge(start, end, left, right)
169168

170169

171-
class ReadOnlyIOWrapper(BinaryIO):
172-
"""Implement read-side ``BinaryIO`` methods wrapping an inner ``BinaryIO``.
170+
class ReadOnlyIOWrapper(IO[bytes]):
171+
"""Implement read-side ``IO[bytes]`` methods wrapping an inner ``IO[bytes]``.
173172
174173
This wrapper is useful because Python currently does not distinguish read-only
175174
streams at the type level.
176175
"""
177176

178-
def __init__(self, inner: BinaryIO) -> None:
177+
def __init__(self, inner: IO[bytes]) -> None:
179178
self._file = inner
180179

181180
def __enter__(self) -> Self:
@@ -296,7 +295,8 @@ def __init__(
296295
session: Session | Authenticator,
297296
delete_backing_file: bool = True,
298297
) -> None:
299-
super().__init__(cast(BinaryIO, NamedTemporaryFile(delete=delete_backing_file)))
298+
inner = NamedTemporaryFile(delete=delete_backing_file) # noqa: SIM115
299+
super().__init__(inner)
300300

301301
self._merge_intervals: MergeIntervals | None = None
302302
self._length: int | None = None

src/poetry/utils/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def extractall(source: Path, dest: Path, zip: bool) -> None:
397397
else:
398398
# These versions of python shipped with a broken tarfile data_filter, per
399399
# https://github.com/python/cpython/issues/107845.
400-
broken_tarfile_filter = {(3, 8, 17), (3, 9, 17), (3, 10, 12), (3, 11, 4)}
400+
broken_tarfile_filter = {(3, 9, 17), (3, 10, 12), (3, 11, 4)}
401401
with tarfile.open(source) as archive:
402402
if (
403403
hasattr(tarfile, "data_filter")

src/poetry/vcs/git/system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def run(*args: Any, **kwargs: Any) -> None:
4040
git_command = find_git_command()
4141
env = os.environ.copy()
4242
env["GIT_TERMINAL_PROMPT"] = "0"
43-
subprocess.check_call( # type: ignore[call-arg]
43+
subprocess.check_call(
4444
git_command + list(args),
4545
stderr=subprocess.DEVNULL,
4646
stdout=subprocess.DEVNULL,

tests/console/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def poetry(
9797
@pytest.fixture
9898
def app(poetry: Poetry) -> PoetryTestApplication:
9999
app_ = PoetryTestApplication(poetry)
100-
app_._load_plugins()
100+
io = NullIO()
101+
app_._load_plugins(io)
101102
return app_
102103

103104

tests/integration/test_utils_vcs_git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ def test_system_git_fallback_on_http_401(
310310

311311
GIT_USERNAME = os.environ.get("POETRY_TEST_INTEGRATION_GIT_USERNAME")
312312
GIT_PASSWORD = os.environ.get("POETRY_TEST_INTEGRATION_GIT_PASSWORD")
313-
HTTP_AUTH_CREDENTIALS_AVAILABLE = not (GIT_USERNAME and GIT_PASSWORD)
313+
HTTP_AUTH_CREDENTIALS_UNAVAILABLE = not (GIT_USERNAME and GIT_PASSWORD)
314314

315315

316316
@pytest.mark.skipif(
317-
HTTP_AUTH_CREDENTIALS_AVAILABLE,
317+
HTTP_AUTH_CREDENTIALS_UNAVAILABLE,
318318
reason="HTTP authentication credentials not available",
319319
)
320320
def test_configured_repository_http_auth(

tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/__init__.pyi

Whitespace-only changes.

0 commit comments

Comments
 (0)