Skip to content

poetry 1.3.0 #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,748 changes: 933 additions & 815 deletions poetry.lock

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ include = [

[tool.poetry.dependencies]
python = "^3.7"
poetry = "^1.2.2"
poetry = "^1.3.0"
poetry-core = "^1.3.0"

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

# only used in github actions
Expand Down Expand Up @@ -64,12 +64,6 @@ strict = true
files = ["src", "tests"]
exclude = ["^tests/fixtures/"]

[[tool.mypy.overrides]]
module = [
'cleo.*',
]
ignore_missing_imports = true

# use of importlib-metadata backport at python3.7 makes it impossible to
# satisfy mypy without some ignores: but we get a different set of ignores at
# different python versions.
Expand Down
4 changes: 3 additions & 1 deletion src/poetry_plugin_export/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def non_optional_groups(self) -> set[str]:
def default_groups(self) -> set[str]:
return {MAIN_GROUP}

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

if not Exporter.is_format_supported(fmt):
Expand Down Expand Up @@ -105,3 +105,5 @@ def handle(self) -> None:
exporter.with_credentials(self.option("with-credentials"))
exporter.with_urls(not self.option("without-urls"))
exporter.export(fmt, Path.cwd(), output or self.io)

return 0
9 changes: 1 addition & 8 deletions src/poetry_plugin_export/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@

from cleo.io.io import IO
from poetry.core.packages.dependency_group import MAIN_GROUP


try:
from poetry.repositories.http_repository import ( # type: ignore[import] # noqa: E501
HTTPRepository,
)
except ImportError: # poetry<1.3.0
from poetry.repositories.http import HTTPRepository
from poetry.repositories.http_repository import HTTPRepository

from poetry_plugin_export.walker import get_project_dependency_packages

Expand Down
7 changes: 4 additions & 3 deletions tests/command/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from cleo.io.null_io import NullIO
from cleo.testers.command_tester import CommandTester
from poetry.console.commands.env_command import EnvCommand
from poetry.console.commands.installer_command import InstallerCommand
from poetry.installation import Installer
from poetry.utils.env import MockEnv

Expand Down Expand Up @@ -64,12 +66,11 @@ def _tester(
app._poetry = poetry

poetry = app.poetry
cmd._pool = poetry.pool

if hasattr(cmd, "set_env"):
if isinstance(cmd, EnvCommand):
cmd.set_env(environment or env)

if hasattr(cmd, "set_installer"):
if isinstance(cmd, InstallerCommand):
installer = installer or Installer(
tester.io,
env,
Expand Down
19 changes: 2 additions & 17 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import cast

import pytest

Expand All @@ -15,15 +14,7 @@
from poetry.factory import Factory
from poetry.layouts import layout
from poetry.repositories import Repository


try:
from poetry.repositories.repository_pool import ( # type: ignore[import] # noqa: E501
RepositoryPool,
)
except ImportError: # poetry<1.3.0
from poetry.repositories.pool import Pool as RepositoryPool

from poetry.repositories.repository_pool import RepositoryPool
from poetry.utils.env import SystemEnv

from tests.helpers import TestLocker
Expand Down Expand Up @@ -180,13 +171,7 @@ def _factory(

poetry = Factory().create_poetry(project_dir)

lock = poetry.locker.lock
if isinstance(lock, Path):
lock_path = cast("Path", lock)
else:
# poetry < 1.3
lock_path = lock.path
locker = TestLocker(lock_path, poetry.locker._local_config)
locker = TestLocker(poetry.locker.lock, poetry.locker._local_config)
locker.write()

poetry.set_locker(locker)
Expand Down
16 changes: 6 additions & 10 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import os

from contextlib import contextmanager
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import Iterator
from typing import cast

from poetry.console.application import Application
from poetry.factory import Factory
Expand All @@ -16,6 +14,8 @@


if TYPE_CHECKING:
from pathlib import Path

from poetry.core.packages.package import Package
from poetry.installation.operations.operation import Operation
from poetry.poetry import Poetry
Expand All @@ -33,13 +33,9 @@ def reset_poetry(self) -> None:
self._poetry = Factory().create_poetry(poetry.file.path.parent)
self._poetry.set_pool(poetry.pool)
self._poetry.set_config(poetry.config)
lock = poetry.locker.lock
if isinstance(lock, Path):
lock_path = cast("Path", lock)
else:
# poetry < 1.3
lock_path = lock.path
self._poetry.set_locker(TestLocker(lock_path, self._poetry.local_config))
self._poetry.set_locker(
TestLocker(poetry.locker.lock, self._poetry.local_config)
)


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

self._lock_data = data # type: ignore[assignment]
self._lock_data = data

def is_fresh(self) -> bool:
return True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def locked(self, is_locked: bool = True) -> Locker:
return self

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

def is_locked(self) -> bool:
return self._locked
Expand Down
2 changes: 1 addition & 1 deletion tests/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class CommandTesterFactory(Protocol):
def __call__(
self: CommandTester,
self,
command: str,
poetry: Poetry | None = None,
installer: Installer | None = None,
Expand Down