Skip to content

Commit 112fdc8

Browse files
authored
chore: bump minimum Poetry version and drop compat code (#167)
1 parent dd00a2f commit 112fdc8

File tree

9 files changed

+953
-864
lines changed

9 files changed

+953
-864
lines changed

poetry.lock

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

pyproject.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ include = [
1818

1919
[tool.poetry.dependencies]
2020
python = "^3.7"
21-
poetry = "^1.2.2"
21+
poetry = "^1.3.0"
2222
poetry-core = "^1.3.0"
2323

2424
[tool.poetry.group.dev.dependencies]
@@ -27,7 +27,7 @@ pytest = "^7.1"
2727
pytest-cov = "^4.0"
2828
pytest-mock = "^3.9"
2929
pytest-randomly = "^3.12"
30-
pytest-xdist = { version = "^2.5", extras = ["psutil"] }
30+
pytest-xdist = { version = "^3.1", extras = ["psutil"] }
3131
mypy = ">=0.971"
3232

3333
# only used in github actions
@@ -64,12 +64,6 @@ strict = true
6464
files = ["src", "tests"]
6565
exclude = ["^tests/fixtures/"]
6666

67-
[[tool.mypy.overrides]]
68-
module = [
69-
'cleo.*',
70-
]
71-
ignore_missing_imports = true
72-
7367
# use of importlib-metadata backport at python3.7 makes it impossible to
7468
# satisfy mypy without some ignores: but we get a different set of ignores at
7569
# different python versions.

src/poetry_plugin_export/command.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def non_optional_groups(self) -> set[str]:
5555
def default_groups(self) -> set[str]:
5656
return {MAIN_GROUP}
5757

58-
def handle(self) -> None:
58+
def handle(self) -> int:
5959
fmt = self.option("format")
6060

6161
if not Exporter.is_format_supported(fmt):
@@ -105,3 +105,5 @@ def handle(self) -> None:
105105
exporter.with_credentials(self.option("with-credentials"))
106106
exporter.with_urls(not self.option("without-urls"))
107107
exporter.export(fmt, Path.cwd(), output or self.io)
108+
109+
return 0

src/poetry_plugin_export/exporter.py

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

99
from cleo.io.io import IO
1010
from poetry.core.packages.dependency_group import MAIN_GROUP
11-
12-
13-
try:
14-
from poetry.repositories.http_repository import ( # type: ignore[import] # noqa: E501
15-
HTTPRepository,
16-
)
17-
except ImportError: # poetry<1.3.0
18-
from poetry.repositories.http import HTTPRepository
11+
from poetry.repositories.http_repository import HTTPRepository
1912

2013
from poetry_plugin_export.walker import get_project_dependency_packages
2114

tests/command/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from cleo.io.null_io import NullIO
88
from cleo.testers.command_tester import CommandTester
9+
from poetry.console.commands.env_command import EnvCommand
10+
from poetry.console.commands.installer_command import InstallerCommand
911
from poetry.installation import Installer
1012
from poetry.utils.env import MockEnv
1113

@@ -64,12 +66,11 @@ def _tester(
6466
app._poetry = poetry
6567

6668
poetry = app.poetry
67-
cmd._pool = poetry.pool
6869

69-
if hasattr(cmd, "set_env"):
70+
if isinstance(cmd, EnvCommand):
7071
cmd.set_env(environment or env)
7172

72-
if hasattr(cmd, "set_installer"):
73+
if isinstance(cmd, InstallerCommand):
7374
installer = installer or Installer(
7475
tester.io,
7576
env,

tests/conftest.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pathlib import Path
66
from typing import TYPE_CHECKING
77
from typing import Any
8-
from typing import cast
98

109
import pytest
1110

@@ -15,15 +14,7 @@
1514
from poetry.factory import Factory
1615
from poetry.layouts import layout
1716
from poetry.repositories import Repository
18-
19-
20-
try:
21-
from poetry.repositories.repository_pool import ( # type: ignore[import] # noqa: E501
22-
RepositoryPool,
23-
)
24-
except ImportError: # poetry<1.3.0
25-
from poetry.repositories.pool import Pool as RepositoryPool
26-
17+
from poetry.repositories.repository_pool import RepositoryPool
2718
from poetry.utils.env import SystemEnv
2819

2920
from tests.helpers import TestLocker
@@ -180,13 +171,7 @@ def _factory(
180171

181172
poetry = Factory().create_poetry(project_dir)
182173

183-
lock = poetry.locker.lock
184-
if isinstance(lock, Path):
185-
lock_path = cast("Path", lock)
186-
else:
187-
# poetry < 1.3
188-
lock_path = lock.path
189-
locker = TestLocker(lock_path, poetry.locker._local_config)
174+
locker = TestLocker(poetry.locker.lock, poetry.locker._local_config)
190175
locker.write()
191176

192177
poetry.set_locker(locker)

tests/helpers.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import os
44

55
from contextlib import contextmanager
6-
from pathlib import Path
76
from typing import TYPE_CHECKING
87
from typing import Any
98
from typing import Iterator
10-
from typing import cast
119

1210
from poetry.console.application import Application
1311
from poetry.factory import Factory
@@ -16,6 +14,8 @@
1614

1715

1816
if TYPE_CHECKING:
17+
from pathlib import Path
18+
1919
from poetry.core.packages.package import Package
2020
from poetry.installation.operations.operation import Operation
2121
from poetry.poetry import Poetry
@@ -33,13 +33,9 @@ def reset_poetry(self) -> None:
3333
self._poetry = Factory().create_poetry(poetry.file.path.parent)
3434
self._poetry.set_pool(poetry.pool)
3535
self._poetry.set_config(poetry.config)
36-
lock = poetry.locker.lock
37-
if isinstance(lock, Path):
38-
lock_path = cast("Path", lock)
39-
else:
40-
# poetry < 1.3
41-
lock_path = lock.path
42-
self._poetry.set_locker(TestLocker(lock_path, self._poetry.local_config))
36+
self._poetry.set_locker(
37+
TestLocker(poetry.locker.lock, self._poetry.local_config)
38+
)
4339

4440

4541
class TestLocker(Locker):
@@ -63,7 +59,7 @@ def locked(self, is_locked: bool = True) -> TestLocker:
6359
def mock_lock_data(self, data: dict[str, Any]) -> None:
6460
self.locked()
6561

66-
self._lock_data = data # type: ignore[assignment]
62+
self._lock_data = data
6763

6864
def is_fresh(self) -> bool:
6965
return True

tests/test_exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def locked(self, is_locked: bool = True) -> Locker:
5454
return self
5555

5656
def mock_lock_data(self, data: dict[str, Any]) -> None:
57-
self._lock_data = data # type: ignore[assignment]
57+
self._lock_data = data
5858

5959
def is_locked(self) -> bool:
6060
return self._locked

tests/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class CommandTesterFactory(Protocol):
1616
def __call__(
17-
self: CommandTester,
17+
self,
1818
command: str,
1919
poetry: Poetry | None = None,
2020
installer: Installer | None = None,

0 commit comments

Comments
 (0)