Skip to content

Commit 7d87de0

Browse files
committed
fix: resolve mypy comparison-overlap and ruff formatting in test_helpers
- Replace `eps == []` with `len(eps) == 0` to fix mypy comparison-overlap error on Python 3.12+ (EntryPoints cannot be compared with list[Never]) - Remove unused imports (Path from pathlib, FIXTURE_PATH) - Move Path import into TYPE_CHECKING block - Apply ruff formatting fixes
1 parent 4c1af1a commit 7d87de0

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

tests/test_helpers.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44

55
from importlib import metadata
6-
from pathlib import Path
76
from typing import TYPE_CHECKING
87

98
import keyring
@@ -14,7 +13,6 @@
1413

1514
from poetry.repositories.exceptions import PackageNotFoundError
1615
from poetry.utils.password_manager import PoetryKeyring
17-
from tests.helpers import FIXTURE_PATH
1816
from tests.helpers import MOCK_DEFAULT_GIT_REVISION
1917
from tests.helpers import MockDulwichRepo
2018
from tests.helpers import TestLocker
@@ -33,6 +31,8 @@
3331

3432

3533
if TYPE_CHECKING:
34+
from pathlib import Path
35+
3636
from pytest_mock import MockerFixture
3737

3838

@@ -239,9 +239,7 @@ def test_write_lock_data_without_write_stores_in_memory(
239239
assert locker._lock_data == data
240240
assert not lock_path.exists()
241241

242-
def test_write_lock_data_with_write_persists_to_file(
243-
self, tmp_path: Path
244-
) -> None:
242+
def test_write_lock_data_with_write_persists_to_file(self, tmp_path: Path) -> None:
245243
lock_path = tmp_path / "poetry.lock"
246244
locker = TestLocker(lock_path, {})
247245
locker.write()
@@ -310,9 +308,7 @@ def test_updates_environ(self) -> None:
310308

311309
def test_clears_and_updates_environ(self) -> None:
312310
os.environ["EXISTING_VAR"] = "existing"
313-
with isolated_environment(
314-
environ={"INJECTED_VAR": "injected"}, clear=True
315-
):
311+
with isolated_environment(environ={"INJECTED_VAR": "injected"}, clear=True):
316312
assert "EXISTING_VAR" not in os.environ
317313
assert os.environ["INJECTED_VAR"] == "injected"
318314
assert os.environ.get("EXISTING_VAR") == "existing"
@@ -359,9 +355,7 @@ class FakePlugin:
359355
assert len(eps) == 1
360356
assert eps[0].name == "my-plugin"
361357

362-
def test_returns_empty_for_different_group(
363-
self, mocker: MockerFixture
364-
) -> None:
358+
def test_returns_empty_for_different_group(self, mocker: MockerFixture) -> None:
365359
class FakePlugin:
366360
group = "poetry.plugin"
367361
__module__ = "my_plugin"
@@ -370,7 +364,7 @@ class FakePlugin:
370364
mock_metadata_entry_points(mocker, FakePlugin)
371365

372366
eps = metadata.entry_points(group="some.other.group")
373-
assert eps == []
367+
assert len(eps) == 0
374368

375369

376370
# --- flatten_dict ---
@@ -494,14 +488,10 @@ def __init__(self) -> None:
494488
def priority(self) -> float:
495489
return 42
496490

497-
def get_password(
498-
self, service: str, username: str
499-
) -> str | None:
491+
def get_password(self, service: str, username: str) -> str | None:
500492
return None
501493

502-
def set_password(
503-
self, service: str, username: str, password: str
504-
) -> None:
494+
def set_password(self, service: str, username: str, password: str) -> None:
505495
pass
506496

507497
def delete_password(self, service: str, username: str) -> None:

0 commit comments

Comments
 (0)