Skip to content

Commit 32ebebd

Browse files
committed
chore: compatibility with poetry 1.4, require poetry 1.4, update dev dependencies
1 parent 5543a73 commit 32ebebd

File tree

8 files changed

+1110
-781
lines changed

8 files changed

+1110
-781
lines changed

poetry.lock

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

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ include = [
1616

1717
[tool.poetry.dependencies]
1818
python = "^3.7"
19-
poetry = "^1.2.0"
19+
poetry = "^1.4.0"
2020

2121
[tool.poetry.dev-dependencies]
22-
pre-commit = "^2.6"
23-
pytest = "^7.1.2"
24-
pytest-mock = "^3.6.1"
25-
mypy = ">=0.950"
22+
pre-commit = ">=2.6"
23+
pytest = ">=7.1.2"
24+
pytest-mock = ">=3.6.1"
25+
mypy = ">=1.1.1"
2626

2727
[tool.poetry.plugins."poetry.application.plugin"]
2828
export = "poetry_plugin_bundle.plugin:BundleApplicationPlugin"

src/poetry_plugin_bundle/bundlers/venv_bundler.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from subprocess import CalledProcessError
77
from typing import TYPE_CHECKING
8-
from typing import cast
98

109
from poetry_plugin_bundle.bundlers.bundler import Bundler
1110

@@ -14,7 +13,8 @@
1413
from pathlib import Path
1514

1615
from cleo.io.io import IO
17-
from poetry.core.semver.version import Version
16+
from cleo.io.outputs.section_output import SectionOutput
17+
from poetry.core.constraints.version import Version
1818
from poetry.poetry import Poetry
1919

2020

@@ -52,10 +52,10 @@ def bundle(self, poetry: Poetry, io: IO) -> bool:
5252
from tempfile import TemporaryDirectory
5353

5454
from cleo.io.null_io import NullIO
55+
from poetry.core.constraints.version import Version
5556
from poetry.core.masonry.builders.wheel import WheelBuilder
5657
from poetry.core.masonry.utils.module import ModuleOrPackageNotFound
5758
from poetry.core.packages.package import Package
58-
from poetry.core.semver.version import Version
5959
from poetry.installation.installer import Installer
6060
from poetry.installation.operations.install import Install
6161
from poetry.utils.env import EnvManager
@@ -74,7 +74,7 @@ def bundle(self, poetry: Poetry, io: IO) -> bool:
7474

7575
message = self._get_message(poetry, self._path)
7676
if io.is_decorated() and not io.is_debug():
77-
io = io.section()
77+
io = io.section() # type: ignore[assignment]
7878

7979
io.write_line(message)
8080

@@ -134,7 +134,10 @@ def bundle(self, poetry: Poetry, io: IO) -> bool:
134134
if self._activated_groups is not None:
135135
installer.only_groups(self._activated_groups)
136136
installer.requires_synchronization()
137-
installer.use_executor(poetry.config.get("experimental.new-installer", False))
137+
use_executor = poetry.config.get("experimental.new-installer", False)
138+
if not use_executor:
139+
# only set if false because the method is deprecated
140+
installer.use_executor(False)
138141

139142
return_code = installer.run()
140143
if return_code:
@@ -202,19 +205,17 @@ def _get_message(
202205
f" (<b>{poetry.package.pretty_version}</b>) into <c2>{path}</c2>"
203206
)
204207

205-
def _write(self, io: IO, message: str) -> None:
208+
def _write(self, io: IO | SectionOutput, message: str) -> None:
206209
from cleo.io.outputs.section_output import SectionOutput
207210

208211
if io.is_debug() or not io.is_decorated() or not isinstance(io, SectionOutput):
209212
io.write_line(message)
210213
return
211214

212-
io = cast(SectionOutput, io)
213215
io.overwrite(message)
214216

215217
def _get_executable_info(self, executable: str) -> tuple[str, Version]:
216-
from poetry.core.semver.version import Version
217-
from poetry.utils._compat import list_to_shell_command
218+
from poetry.core.constraints.version import Version
218219

219220
try:
220221
python_version = Version.parse(executable)
@@ -227,17 +228,14 @@ def _get_executable_info(self, executable: str) -> tuple[str, Version]:
227228

228229
try:
229230
python_version_str = subprocess.check_output(
230-
list_to_shell_command(
231-
[
232-
executable,
233-
"-c",
234-
(
235-
"\"import sys; print('.'.join([str(s) for s in"
236-
' sys.version_info[:3]]))"'
237-
),
238-
]
239-
),
240-
shell=True,
231+
[
232+
executable,
233+
"-c",
234+
(
235+
"import sys; print('.'.join([str(s) for s in"
236+
" sys.version_info[:3]]))"
237+
),
238+
]
241239
).decode()
242240
except CalledProcessError as e:
243241
from poetry.utils.env import EnvCommandError

src/poetry_plugin_bundle/plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ def commands(self) -> list[type[Command]]:
2222
return [BundleVenvCommand]
2323

2424
def activate(self, application: Application) -> None:
25+
assert application.event_dispatcher
2526
application.event_dispatcher.add_listener(
26-
COMMAND, self.configure_bundle_commands
27+
COMMAND, self.configure_bundle_commands # type: ignore[arg-type]
2728
)
2829
super().activate(application=application)
2930

tests/bundlers/test_venv_bundler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from poetry.core.packages.package import Package
1414
from poetry.factory import Factory
1515
from poetry.puzzle.exceptions import SolverProblemError
16-
from poetry.repositories.pool import Pool
1716
from poetry.repositories.repository import Repository
17+
from poetry.repositories.repository_pool import RepositoryPool
1818

1919
from poetry_plugin_bundle.bundlers.venv_bundler import VenvBundler
2020

@@ -43,7 +43,7 @@ def poetry(config: Config) -> Poetry:
4343
)
4444
poetry.set_config(config)
4545

46-
pool = Pool()
46+
pool = RepositoryPool()
4747
repository = Repository("repo")
4848
repository.add_package(Package("foo", "1.0.0"))
4949
pool.add_repository(repository)
@@ -196,7 +196,7 @@ def test_bundler_should_display_a_warning_for_projects_with_no_module(
196196
)
197197
poetry.set_config(config)
198198

199-
pool = Pool()
199+
pool = RepositoryPool()
200200
repository = Repository("repo")
201201
repository.add_package(Package("foo", "1.0.0"))
202202
pool.add_repository(repository)
@@ -235,7 +235,7 @@ def test_bundler_can_filter_dependency_groups(
235235
# foo is in the main dependency group
236236
# bar is a dev dependency
237237
# add a repository for foo but not bar
238-
pool = Pool()
238+
pool = RepositoryPool()
239239
repository = Repository("repo")
240240
repository.add_package(Package("foo", "1.0.0"))
241241
pool.add_repository(repository)

tests/console/commands/bundle/test_venv.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from pathlib import Path
44
from typing import TYPE_CHECKING
55

6+
from poetry.console.application import Application
7+
68
from poetry_plugin_bundle.bundlers.venv_bundler import VenvBundler
79

810

@@ -32,6 +34,7 @@ def test_venv_calls_venv_bundler(
3234
assert app_tester.execute("bundle venv /foo --only dev") == 1
3335
assert app_tester.execute("bundle venv /foo --without main --with dev") == 1
3436

37+
assert isinstance(app_tester.application, Application)
3538
assert [
3639
mocker.call(app_tester.application.poetry, mocker.ANY),
3740
mocker.call(app_tester.application.poetry, mocker.ANY),

tests/console/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def poetry(project_directory: str, config: Config) -> Poetry:
2727
p = Factory().create_poetry(
2828
Path(__file__).parent.parent / "fixtures" / project_directory
2929
)
30-
p.set_locker(TestLocker(p.locker.lock.path, p.locker._local_config))
30+
p.set_locker(TestLocker(p.locker.lock, p.locker._local_config))
3131

3232
return p
3333

tests/helpers.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import Any
55

66
from poetry.console.application import Application
7-
from poetry.core.toml.file import TOMLFile
87
from poetry.factory import Factory
98
from poetry.packages import Locker
109

@@ -28,16 +27,13 @@ def reset_poetry(self) -> None:
2827
self._poetry.set_pool(poetry.pool)
2928
self._poetry.set_config(poetry.config)
3029
self._poetry.set_locker(
31-
TestLocker(poetry.locker.lock.path, self._poetry.local_config)
30+
TestLocker(poetry.locker.lock, self._poetry.local_config)
3231
)
3332

3433

3534
class TestLocker(Locker):
3635
def __init__(self, lock: str | Path, local_config: dict[str, Any]) -> None:
37-
self._lock = TOMLFile(lock)
38-
self._local_config = local_config
39-
self._lock_data: TOMLDocument | None = None
40-
self._content_hash = self._get_content_hash()
36+
super().__init__(lock, local_config)
4137
self._locked = False
4238
self._write = False
4339

0 commit comments

Comments
 (0)