From b3462f6a8f8acccfba094c662cabab7992e16002 Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Sat, 15 Oct 2022 22:26:59 +0200 Subject: [PATCH 1/6] refactor: rename http to http_repository --- src/poetry/installation/pip_installer.py | 2 +- src/poetry/repositories/{http.py => http_repository.py} | 0 src/poetry/repositories/legacy_repository.py | 2 +- src/poetry/repositories/pypi_repository.py | 2 +- tests/conftest.py | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename src/poetry/repositories/{http.py => http_repository.py} (100%) diff --git a/src/poetry/installation/pip_installer.py b/src/poetry/installation/pip_installer.py index 7ee24915f62..8a967d49569 100644 --- a/src/poetry/installation/pip_installer.py +++ b/src/poetry/installation/pip_installer.py @@ -14,7 +14,7 @@ from poetry.core.pyproject.toml import PyProjectTOML from poetry.installation.base_installer import BaseInstaller -from poetry.repositories.http import HTTPRepository +from poetry.repositories.http_repository import HTTPRepository from poetry.utils._compat import encode from poetry.utils.helpers import remove_directory from poetry.utils.pip import pip_install diff --git a/src/poetry/repositories/http.py b/src/poetry/repositories/http_repository.py similarity index 100% rename from src/poetry/repositories/http.py rename to src/poetry/repositories/http_repository.py diff --git a/src/poetry/repositories/legacy_repository.py b/src/poetry/repositories/legacy_repository.py index 9eaf286928b..6ab2d819ea9 100644 --- a/src/poetry/repositories/legacy_repository.py +++ b/src/poetry/repositories/legacy_repository.py @@ -7,7 +7,7 @@ from poetry.inspection.info import PackageInfo from poetry.repositories.exceptions import PackageNotFound -from poetry.repositories.http import HTTPRepository +from poetry.repositories.http_repository import HTTPRepository from poetry.repositories.link_sources.html import SimpleRepositoryPage diff --git a/src/poetry/repositories/pypi_repository.py b/src/poetry/repositories/pypi_repository.py index 8846b417739..236dabadfda 100644 --- a/src/poetry/repositories/pypi_repository.py +++ b/src/poetry/repositories/pypi_repository.py @@ -15,7 +15,7 @@ from poetry.core.version.exceptions import InvalidVersion from poetry.repositories.exceptions import PackageNotFound -from poetry.repositories.http import HTTPRepository +from poetry.repositories.http_repository import HTTPRepository from poetry.repositories.link_sources.json import SimpleJsonPage from poetry.utils._compat import to_str from poetry.utils.constants import REQUESTS_TIMEOUT diff --git a/tests/conftest.py b/tests/conftest.py index 5de0afdd013..a6bcf577c55 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -231,7 +231,7 @@ def download_mock(mocker: MockerFixture) -> None: # Patch download to not download anything but to just copy from fixtures mocker.patch("poetry.utils.helpers.download_file", new=mock_download) mocker.patch("poetry.puzzle.provider.download_file", new=mock_download) - mocker.patch("poetry.repositories.http.download_file", new=mock_download) + mocker.patch("poetry.repositories.http_repository.download_file", new=mock_download) @pytest.fixture(autouse=True) From ceae605c2aaea772c2cd7a1c7b63b05322149ddb Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Sat, 15 Oct 2022 22:30:13 +0200 Subject: [PATCH 2/6] refactor: deprecate poetry.repositories.http --- src/poetry/repositories/http.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/poetry/repositories/http.py diff --git a/src/poetry/repositories/http.py b/src/poetry/repositories/http.py new file mode 100644 index 00000000000..3de1408a0ce --- /dev/null +++ b/src/poetry/repositories/http.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +import warnings + + +from poetry.repositories.http_repository import ( # isort: skip # nopycln: import # noqa: E501, F401 + HTTPRepository, +) + +warnings.warn( + "Module poetry.repositories.http is renamed and scheduled for removal in poetry" + " release 1.4.0. Please migrate to poetry.repositories.http_repository.", + DeprecationWarning, + stacklevel=2, +) From 926d0a0a253fef59d651594fdc6bc54d5925dba3 Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Mon, 3 Oct 2022 20:18:42 +0200 Subject: [PATCH 3/6] refactor: rename cached to cached_repository --- src/poetry/repositories/{cached.py => cached_repository.py} | 0 src/poetry/repositories/http_repository.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/poetry/repositories/{cached.py => cached_repository.py} (100%) diff --git a/src/poetry/repositories/cached.py b/src/poetry/repositories/cached_repository.py similarity index 100% rename from src/poetry/repositories/cached.py rename to src/poetry/repositories/cached_repository.py diff --git a/src/poetry/repositories/http_repository.py b/src/poetry/repositories/http_repository.py index 07315736d5a..d0dafcccd36 100644 --- a/src/poetry/repositories/http_repository.py +++ b/src/poetry/repositories/http_repository.py @@ -18,7 +18,7 @@ from poetry.core.utils.helpers import temporary_directory from poetry.core.version.markers import parse_marker -from poetry.repositories.cached import CachedRepository +from poetry.repositories.cached_repository import CachedRepository from poetry.repositories.exceptions import PackageNotFound from poetry.repositories.exceptions import RepositoryError from poetry.repositories.link_sources.html import HTMLPage From 73a152abb449a414dae7a2fd0ca1663f0d15bfb9 Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Mon, 17 Oct 2022 22:03:38 +0200 Subject: [PATCH 4/6] refactor: deprecate poetry.repositories.cached --- src/poetry/repositories/cached.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/poetry/repositories/cached.py diff --git a/src/poetry/repositories/cached.py b/src/poetry/repositories/cached.py new file mode 100644 index 00000000000..8a9443966de --- /dev/null +++ b/src/poetry/repositories/cached.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +import warnings + + +from poetry.repositories.cached_repository import ( # isort: skip # nopycln: import # noqa: E501, F401 + CachedRepository, +) + +warnings.warn( + "Module poetry.repositories.cached is renamed and scheduled for removal in poetry" + " release 1.4.0. Please migrate to poetry.repositories.cached_repository.", + DeprecationWarning, + stacklevel=2, +) From 71ac6524f0b5f57852cdcd943ec77537c201125a Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Sat, 15 Oct 2022 22:24:22 +0200 Subject: [PATCH 5/6] refactor: rename Pool to RepositoryPool --- src/poetry/console/commands/debug/resolve.py | 4 +- src/poetry/console/commands/init.py | 10 +-- src/poetry/console/commands/show.py | 4 +- src/poetry/console/commands/source/add.py | 4 +- src/poetry/installation/chooser.py | 6 +- src/poetry/installation/executor.py | 4 +- src/poetry/installation/installer.py | 6 +- src/poetry/installation/pip_installer.py | 4 +- src/poetry/poetry.py | 10 +-- src/poetry/puzzle/provider.py | 6 +- src/poetry/puzzle/solver.py | 4 +- src/poetry/repositories/__init__.py | 4 +- .../{pool.py => repository_pool.py} | 8 +- src/poetry/version/version_selector.py | 4 +- tests/conftest.py | 4 +- tests/console/commands/self/conftest.py | 17 +++-- tests/console/commands/test_init.py | 5 +- tests/installation/test_chooser.py | 32 +++++--- tests/installation/test_executor.py | 60 +++++++++------ tests/installation/test_installer.py | 22 +++--- tests/installation/test_installer_old.py | 20 ++--- tests/installation/test_pip_installer.py | 24 +++--- tests/mixology/version_solver/conftest.py | 8 +- .../mixology/version_solver/test_with_lock.py | 18 ++--- tests/puzzle/test_provider.py | 8 +- tests/puzzle/test_solver.py | 76 ++++++++++--------- .../{test_pool.py => test_repository_pool.py} | 42 +++++----- 27 files changed, 227 insertions(+), 187 deletions(-) rename src/poetry/repositories/{pool.py => repository_pool.py} (96%) rename tests/repositories/{test_pool.py => test_repository_pool.py} (91%) diff --git a/src/poetry/console/commands/debug/resolve.py b/src/poetry/console/commands/debug/resolve.py index 61b87352cc0..cd8bd3ed466 100644 --- a/src/poetry/console/commands/debug/resolve.py +++ b/src/poetry/console/commands/debug/resolve.py @@ -36,8 +36,8 @@ def handle(self) -> int: from poetry.factory import Factory from poetry.puzzle.solver import Solver - from poetry.repositories.pool import Pool from poetry.repositories.repository import Repository + from poetry.repositories.repository_pool import RepositoryPool from poetry.utils.env import EnvManager packages = self.argument("package") @@ -107,7 +107,7 @@ def handle(self) -> int: if self.option("install"): env = EnvManager(self.poetry).get() - pool = Pool() + pool = RepositoryPool() locked_repository = Repository("poetry-locked") for op in ops: locked_repository.add_package(op.package) diff --git a/src/poetry/console/commands/init.py b/src/poetry/console/commands/init.py index e2ebf9cf9b7..af259f5c059 100644 --- a/src/poetry/console/commands/init.py +++ b/src/poetry/console/commands/init.py @@ -23,7 +23,7 @@ from poetry.core.packages.package import Package from tomlkit.items import InlineTable - from poetry.repositories import Pool + from poetry.repositories import RepositoryPool Requirements = Dict[str, Union[str, Mapping[str, Any]]] @@ -66,7 +66,7 @@ class InitCommand(Command): def __init__(self) -> None: super().__init__() - self._pool: Pool | None = None + self._pool: RepositoryPool | None = None def handle(self) -> int: from pathlib import Path @@ -462,15 +462,15 @@ def _validate_package(package: str | None) -> str | None: return package - def _get_pool(self) -> Pool: - from poetry.repositories import Pool + def _get_pool(self) -> RepositoryPool: + from poetry.repositories import RepositoryPool from poetry.repositories.pypi_repository import PyPiRepository if isinstance(self, EnvCommand): return self.poetry.pool if self._pool is None: - self._pool = Pool() + self._pool = RepositoryPool() self._pool.add_repository(PyPiRepository()) return self._pool diff --git a/src/poetry/console/commands/show.py b/src/poetry/console/commands/show.py index 7b0c55b3e24..5f8e4f0db0f 100644 --- a/src/poetry/console/commands/show.py +++ b/src/poetry/console/commands/show.py @@ -194,11 +194,11 @@ def _display_packages_information( from poetry.puzzle.solver import Solver from poetry.repositories.installed_repository import InstalledRepository - from poetry.repositories.pool import Pool + from poetry.repositories.repository_pool import RepositoryPool from poetry.utils.helpers import get_package_version_display_string locked_packages = locked_repository.packages - pool = Pool(ignore_repository_names=True) + pool = RepositoryPool(ignore_repository_names=True) pool.add_repository(locked_repository) solver = Solver( root, diff --git a/src/poetry/console/commands/source/add.py b/src/poetry/console/commands/source/add.py index 3011980c529..e5750d77472 100644 --- a/src/poetry/console/commands/source/add.py +++ b/src/poetry/console/commands/source/add.py @@ -34,7 +34,7 @@ class SourceAddCommand(Command): def handle(self) -> int: from poetry.factory import Factory - from poetry.repositories import Pool + from poetry.repositories import RepositoryPool from poetry.utils.source import source_to_table name = self.argument("name") @@ -83,7 +83,7 @@ def handle(self) -> int: sources.append(source_to_table(new_source)) # ensure new source is valid. eg: invalid name etc. - self.poetry._pool = Pool() + self.poetry._pool = RepositoryPool() try: Factory.configure_sources( self.poetry, sources, self.poetry.config, NullIO() diff --git a/src/poetry/installation/chooser.py b/src/poetry/installation/chooser.py index d5ee2c6d57f..a5432cdd386 100644 --- a/src/poetry/installation/chooser.py +++ b/src/poetry/installation/chooser.py @@ -18,7 +18,7 @@ from poetry.core.packages.package import Package from poetry.core.packages.utils.link import Link - from poetry.repositories.pool import Pool + from poetry.repositories.repository_pool import RepositoryPool from poetry.utils.env import Env @@ -61,7 +61,9 @@ class Chooser: A Chooser chooses an appropriate release archive for packages. """ - def __init__(self, pool: Pool, env: Env, config: Config | None = None) -> None: + def __init__( + self, pool: RepositoryPool, env: Env, config: Config | None = None + ) -> None: self._pool = pool self._env = env self._config = config or Config.create() diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py index e831d4d0d34..38e0065e31d 100644 --- a/src/poetry/installation/executor.py +++ b/src/poetry/installation/executor.py @@ -41,7 +41,7 @@ from poetry.config.config import Config from poetry.installation.operations.operation import Operation - from poetry.repositories import Pool + from poetry.repositories import RepositoryPool from poetry.utils.env import Env @@ -49,7 +49,7 @@ class Executor: def __init__( self, env: Env, - pool: Pool, + pool: RepositoryPool, config: Config, io: IO, parallel: bool | None = None, diff --git a/src/poetry/installation/installer.py b/src/poetry/installation/installer.py index e3cdcb9e0ed..9b906f7678f 100644 --- a/src/poetry/installation/installer.py +++ b/src/poetry/installation/installer.py @@ -10,8 +10,8 @@ from poetry.installation.operations import Uninstall from poetry.installation.operations import Update from poetry.installation.pip_installer import PipInstaller -from poetry.repositories import Pool from poetry.repositories import Repository +from poetry.repositories import RepositoryPool from poetry.repositories.installed_repository import InstalledRepository from poetry.repositories.lockfile_repository import LockfileRepository from poetry.utils.extras import get_extra_package_names @@ -39,7 +39,7 @@ def __init__( env: Env, package: ProjectPackage, locker: Locker, - pool: Pool, + pool: RepositoryPool, config: Config, installed: Repository | None = None, executor: Executor | None = None, @@ -300,7 +300,7 @@ def _do_install(self) -> int: ) # We resolve again by only using the lock file - pool = Pool(ignore_repository_names=True) + pool = RepositoryPool(ignore_repository_names=True) # Making a new repo containing the packages # newly resolved and the ones from the current lock file diff --git a/src/poetry/installation/pip_installer.py b/src/poetry/installation/pip_installer.py index 8a967d49569..884dd1895df 100644 --- a/src/poetry/installation/pip_installer.py +++ b/src/poetry/installation/pip_installer.py @@ -25,12 +25,12 @@ from poetry.core.masonry.builders.builder import Builder from poetry.core.packages.package import Package - from poetry.repositories.pool import Pool + from poetry.repositories.repository_pool import RepositoryPool from poetry.utils.env import Env class PipInstaller(BaseInstaller): - def __init__(self, env: Env, io: IO, pool: Pool) -> None: + def __init__(self, env: Env, io: IO, pool: RepositoryPool) -> None: self._env = env self._io = io self._pool = pool diff --git a/src/poetry/poetry.py b/src/poetry/poetry.py index 42ceff2e47e..e9cb6e5db04 100644 --- a/src/poetry/poetry.py +++ b/src/poetry/poetry.py @@ -17,7 +17,7 @@ from poetry.config.config import Config from poetry.packages.locker import Locker from poetry.plugins.plugin_manager import PluginManager - from poetry.repositories.pool import Pool + from poetry.repositories.repository_pool import RepositoryPool class Poetry(BasePoetry): @@ -32,13 +32,13 @@ def __init__( config: Config, disable_cache: bool = False, ) -> None: - from poetry.repositories.pool import Pool + from poetry.repositories.repository_pool import RepositoryPool super().__init__(file, local_config, package) self._locker = locker self._config = config - self._pool = Pool() + self._pool = RepositoryPool() self._plugin_manager: PluginManager | None = None self._disable_cache = disable_cache @@ -47,7 +47,7 @@ def locker(self) -> Locker: return self._locker @property - def pool(self) -> Pool: + def pool(self) -> RepositoryPool: return self._pool @property @@ -63,7 +63,7 @@ def set_locker(self, locker: Locker) -> Poetry: return self - def set_pool(self, pool: Pool) -> Poetry: + def set_pool(self, pool: RepositoryPool) -> Poetry: self._pool = pool return self diff --git a/src/poetry/puzzle/provider.py b/src/poetry/puzzle/provider.py index 1e634995dd7..4d2e2d30b67 100644 --- a/src/poetry/puzzle/provider.py +++ b/src/poetry/puzzle/provider.py @@ -52,7 +52,7 @@ from poetry.core.packages.vcs_dependency import VCSDependency from poetry.core.version.markers import BaseMarker - from poetry.repositories import Pool + from poetry.repositories import RepositoryPool from poetry.utils.env import Env @@ -124,7 +124,7 @@ class Provider: def __init__( self, package: Package, - pool: Pool, + pool: RepositoryPool, io: IO, *, installed: list[Package] | None = None, @@ -156,7 +156,7 @@ def __init__( ) @property - def pool(self) -> Pool: + def pool(self) -> RepositoryPool: return self._pool @property diff --git a/src/poetry/puzzle/solver.py b/src/poetry/puzzle/solver.py index 3a9f9b89d22..d38a2e0c277 100644 --- a/src/poetry/puzzle/solver.py +++ b/src/poetry/puzzle/solver.py @@ -31,7 +31,7 @@ from poetry.packages import DependencyPackage from poetry.puzzle.transaction import Transaction - from poetry.repositories import Pool + from poetry.repositories import RepositoryPool from poetry.utils.env import Env @@ -39,7 +39,7 @@ class Solver: def __init__( self, package: ProjectPackage, - pool: Pool, + pool: RepositoryPool, installed: list[Package], locked: list[Package], io: IO, diff --git a/src/poetry/repositories/__init__.py b/src/poetry/repositories/__init__.py index ca887e51aa5..d923a9691aa 100644 --- a/src/poetry/repositories/__init__.py +++ b/src/poetry/repositories/__init__.py @@ -1,7 +1,7 @@ from __future__ import annotations -from poetry.repositories.pool import Pool from poetry.repositories.repository import Repository +from poetry.repositories.repository_pool import RepositoryPool -__all__ = ["Pool", "Repository"] +__all__ = ["Repository", "RepositoryPool"] diff --git a/src/poetry/repositories/pool.py b/src/poetry/repositories/repository_pool.py similarity index 96% rename from src/poetry/repositories/pool.py rename to src/poetry/repositories/repository_pool.py index 8a345b16cfc..79d70479c82 100644 --- a/src/poetry/repositories/pool.py +++ b/src/poetry/repositories/repository_pool.py @@ -33,13 +33,13 @@ class PrioritizedRepository: priority: Priority -class Pool(AbstractRepository): +class RepositoryPool(AbstractRepository): def __init__( self, repositories: list[Repository] | None = None, ignore_repository_names: bool = False, ) -> None: - super().__init__("poetry-pool") + super().__init__("poetry-repository-pool") self._repositories: OrderedDict[str, PrioritizedRepository] = OrderedDict() self._ignore_repository_names = ignore_repository_names @@ -78,7 +78,7 @@ def repository(self, name: str) -> Repository: def add_repository( self, repository: Repository, default: bool = False, secondary: bool = False - ) -> Pool: + ) -> RepositoryPool: """ Adds a repository to the pool. """ @@ -101,7 +101,7 @@ def add_repository( ) return self - def remove_repository(self, name: str) -> Pool: + def remove_repository(self, name: str) -> RepositoryPool: if not self.has_repository(name): raise IndexError(f"Pool can not remove unknown repository '{name}'.") del self._repositories[name.lower()] diff --git a/src/poetry/version/version_selector.py b/src/poetry/version/version_selector.py index 476e3635444..d00e52f3c7c 100644 --- a/src/poetry/version/version_selector.py +++ b/src/poetry/version/version_selector.py @@ -8,11 +8,11 @@ if TYPE_CHECKING: from poetry.core.packages.package import Package - from poetry.repositories import Pool + from poetry.repositories import RepositoryPool class VersionSelector: - def __init__(self, pool: Pool) -> None: + def __init__(self, pool: RepositoryPool) -> None: self._pool = pool def find_best_candidate( diff --git a/tests/conftest.py b/tests/conftest.py index a6bcf577c55..8209d2b286e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -24,8 +24,8 @@ from poetry.inspection.info import PackageInfo from poetry.inspection.info import PackageInfoError from poetry.layouts import layout -from poetry.repositories import Pool from poetry.repositories import Repository +from poetry.repositories import RepositoryPool from poetry.utils.env import EnvManager from poetry.utils.env import SystemEnv from poetry.utils.env import VirtualEnv @@ -419,7 +419,7 @@ def _factory( poetry.set_locker(locker) poetry.set_config(config) - pool = Pool() + pool = RepositoryPool() pool.add_repository(repo) poetry.set_pool(pool) diff --git a/tests/console/commands/self/conftest.py b/tests/console/commands/self/conftest.py index 6a175b5fdf0..e6fa5a052bf 100644 --- a/tests/console/commands/self/conftest.py +++ b/tests/console/commands/self/conftest.py @@ -7,7 +7,7 @@ from poetry.core.packages.package import Package from poetry.__version__ import __version__ -from poetry.repositories import Pool +from poetry.repositories import RepositoryPool from poetry.utils.env import EnvManager @@ -34,8 +34,8 @@ def save_environ(environ: None) -> Repository: @pytest.fixture() -def pool(repo: TestRepository) -> Pool: - return Pool([repo]) +def pool(repo: TestRepository) -> RepositoryPool: + return RepositoryPool([repo]) @pytest.fixture(autouse=True) @@ -43,12 +43,17 @@ def setup_mocks( mocker: MockerFixture, tmp_venv: VirtualEnv, installed: Repository, - pool: Pool, + pool: RepositoryPool, http: type[httpretty.httpretty], ) -> None: mocker.patch.object(EnvManager, "get_system_env", return_value=tmp_venv) - mocker.patch("poetry.repositories.pool.Pool.find_packages", pool.find_packages) - mocker.patch("poetry.repositories.pool.Pool.package", pool.package) + mocker.patch( + "poetry.repositories.repository_pool.RepositoryPool.find_packages", + pool.find_packages, + ) + mocker.patch( + "poetry.repositories.repository_pool.RepositoryPool.package", pool.package + ) mocker.patch("poetry.installation.executor.pip_install") mocker.patch( "poetry.installation.installer.Installer._get_installed", diff --git a/tests/console/commands/test_init.py b/tests/console/commands/test_init.py index 5f176ba0eb9..935e58e636e 100644 --- a/tests/console/commands/test_init.py +++ b/tests/console/commands/test_init.py @@ -13,7 +13,7 @@ from packaging.utils import canonicalize_name from poetry.console.commands.init import InitCommand -from poetry.repositories import Pool +from poetry.repositories import RepositoryPool from poetry.utils._compat import decode from tests.helpers import PoetryTestApplication from tests.helpers import get_package @@ -46,7 +46,8 @@ def source_dir(tmp_path: Path) -> Iterator[Path]: def patches(mocker: MockerFixture, source_dir: Path, repo: TestRepository) -> None: mocker.patch("pathlib.Path.cwd", return_value=source_dir) mocker.patch( - "poetry.console.commands.init.InitCommand._get_pool", return_value=Pool([repo]) + "poetry.console.commands.init.InitCommand._get_pool", + return_value=RepositoryPool([repo]), ) diff --git a/tests/installation/test_chooser.py b/tests/installation/test_chooser.py index b4a8d36bc26..0c82faacf61 100644 --- a/tests/installation/test_chooser.py +++ b/tests/installation/test_chooser.py @@ -13,8 +13,8 @@ from poetry.installation.chooser import Chooser from poetry.repositories.legacy_repository import LegacyRepository -from poetry.repositories.pool import Pool from poetry.repositories.pypi_repository import PyPiRepository +from poetry.repositories.repository_pool import RepositoryPool from poetry.utils.env import MockEnv @@ -111,8 +111,8 @@ def callback( @pytest.fixture() -def pool() -> Pool: - pool = Pool() +def pool() -> RepositoryPool: + pool = RepositoryPool() pool.add_repository(PyPiRepository(disable_cache=True)) pool.add_repository( @@ -127,7 +127,11 @@ def pool() -> Pool: @pytest.mark.parametrize("source_type", ["", "legacy"]) def test_chooser_chooses_universal_wheel_link_if_available( - env: MockEnv, mock_pypi: None, mock_legacy: None, source_type: str, pool: Pool + env: MockEnv, + mock_pypi: None, + mock_legacy: None, + source_type: str, + pool: RepositoryPool, ): chooser = Chooser(pool, env) @@ -162,7 +166,7 @@ def test_chooser_no_binary_policy( mock_pypi: None, mock_legacy: None, source_type: str, - pool: Pool, + pool: RepositoryPool, policy: str, filename: str, config: Config, @@ -188,7 +192,11 @@ def test_chooser_no_binary_policy( @pytest.mark.parametrize("source_type", ["", "legacy"]) def test_chooser_chooses_specific_python_universal_wheel_link_if_available( - env: MockEnv, mock_pypi: None, mock_legacy: None, source_type: str, pool: Pool + env: MockEnv, + mock_pypi: None, + mock_legacy: None, + source_type: str, + pool: RepositoryPool, ): chooser = Chooser(pool, env) @@ -209,7 +217,7 @@ def test_chooser_chooses_specific_python_universal_wheel_link_if_available( @pytest.mark.parametrize("source_type", ["", "legacy"]) def test_chooser_chooses_system_specific_wheel_link_if_available( - mock_pypi: None, mock_legacy: None, source_type: str, pool: Pool + mock_pypi: None, mock_legacy: None, source_type: str, pool: RepositoryPool ): env = MockEnv( supported_tags=[Tag("cp37", "cp37m", "win32"), Tag("py3", "none", "any")] @@ -237,7 +245,7 @@ def test_chooser_chooses_sdist_if_no_compatible_wheel_link_is_available( mock_pypi: None, mock_legacy: None, source_type: str, - pool: Pool, + pool: RepositoryPool, ): chooser = Chooser(pool, env) @@ -262,7 +270,7 @@ def test_chooser_chooses_distributions_that_match_the_package_hashes( mock_pypi: None, mock_legacy: None, source_type: str, - pool: Pool, + pool: RepositoryPool, ): chooser = Chooser(pool, env) @@ -295,7 +303,7 @@ def test_chooser_chooses_yanked_if_no_others( mock_pypi: None, mock_legacy: None, source_type: str, - pool: Pool, + pool: RepositoryPool, ) -> None: chooser = Chooser(pool, env) @@ -326,7 +334,7 @@ def test_chooser_chooses_yanked_if_no_others( def test_chooser_does_not_choose_yanked_if_others( mock_legacy: None, mock_legacy_partial_yank: None, - pool: Pool, + pool: RepositoryPool, ) -> None: chooser = Chooser(pool, MockEnv(supported_tags=[Tag("py2", "none", "any")])) @@ -372,7 +380,7 @@ def test_chooser_throws_an_error_if_package_hashes_do_not_match( mock_pypi: None, mock_legacy: None, source_type: None, - pool: Pool, + pool: RepositoryPool, ): chooser = Chooser(pool, env) diff --git a/tests/installation/test_executor.py b/tests/installation/test_executor.py index a5aa06b110e..6b8de09546b 100644 --- a/tests/installation/test_executor.py +++ b/tests/installation/test_executor.py @@ -20,7 +20,7 @@ from poetry.installation.operations import Install from poetry.installation.operations import Uninstall from poetry.installation.operations import Update -from poetry.repositories.pool import Pool +from poetry.repositories.repository_pool import RepositoryPool from poetry.utils.env import MockEnv from tests.repositories.test_pypi_repository import MockRepository @@ -73,8 +73,8 @@ def io_not_decorated() -> BufferedIO: @pytest.fixture() -def pool() -> Pool: - pool = Pool() +def pool() -> RepositoryPool: + pool = RepositoryPool() pool.add_repository(MockRepository()) return pool @@ -102,7 +102,7 @@ def callback( def test_execute_executes_a_batch_of_operations( mocker: MockerFixture, config: Config, - pool: Pool, + pool: RepositoryPool, io: BufferedIO, tmp_dir: str, mock_file_downloads: None, @@ -203,7 +203,7 @@ def test_execute_executes_a_batch_of_operations( ) def test_execute_prints_warning_for_yanked_package( config: Config, - pool: Pool, + pool: RepositoryPool, io: BufferedIO, tmp_dir: str, mock_file_downloads: None, @@ -234,7 +234,11 @@ def test_execute_prints_warning_for_yanked_package( def test_execute_shows_skipped_operations_if_verbose( - config: Config, pool: Pool, io: BufferedIO, config_cache_dir: Path, env: MockEnv + config: Config, + pool: RepositoryPool, + io: BufferedIO, + config_cache_dir: Path, + env: MockEnv, ): config.merge({"cache-dir": config_cache_dir.as_posix()}) @@ -258,7 +262,11 @@ def test_execute_shows_skipped_operations_if_verbose( def test_execute_should_show_errors( - config: Config, pool: Pool, mocker: MockerFixture, io: BufferedIO, env: MockEnv + config: Config, + pool: RepositoryPool, + mocker: MockerFixture, + io: BufferedIO, + env: MockEnv, ): executor = Executor(env, pool, config, io) executor.verbose() @@ -283,7 +291,7 @@ def test_execute_should_show_errors( def test_execute_works_with_ansi_output( mocker: MockerFixture, config: Config, - pool: Pool, + pool: RepositoryPool, io_decorated: BufferedIO, tmp_dir: str, mock_file_downloads: None, @@ -325,7 +333,7 @@ def test_execute_works_with_ansi_output( def test_execute_works_with_no_ansi_output( mocker: MockerFixture, config: Config, - pool: Pool, + pool: RepositoryPool, io_not_decorated: BufferedIO, tmp_dir: str, mock_file_downloads: None, @@ -358,7 +366,11 @@ def test_execute_works_with_no_ansi_output( def test_execute_should_show_operation_as_cancelled_on_subprocess_keyboard_interrupt( - config: Config, pool: Pool, mocker: MockerFixture, io: BufferedIO, env: MockEnv + config: Config, + pool: RepositoryPool, + mocker: MockerFixture, + io: BufferedIO, + env: MockEnv, ): executor = Executor(env, pool, config, io) executor.verbose() @@ -379,7 +391,11 @@ def test_execute_should_show_operation_as_cancelled_on_subprocess_keyboard_inter def test_execute_should_gracefully_handle_io_error( - config: Config, pool: Pool, mocker: MockerFixture, io: BufferedIO, env: MockEnv + config: Config, + pool: RepositoryPool, + mocker: MockerFixture, + io: BufferedIO, + env: MockEnv, ): executor = Executor(env, pool, config, io) executor.verbose() @@ -410,7 +426,7 @@ def test_executor_should_delete_incomplete_downloads( io: BufferedIO, tmp_dir: str, mocker: MockerFixture, - pool: Pool, + pool: RepositoryPool, mock_file_downloads: None, env: MockEnv, ): @@ -488,7 +504,7 @@ def test_executor_should_not_write_pep610_url_references_for_cached_package( mocker: MockerFixture, fixture_dir: FixtureDirGetter, tmp_venv: VirtualEnv, - pool: Pool, + pool: RepositoryPool, config: Config, io: BufferedIO, ): @@ -504,7 +520,7 @@ def test_executor_should_not_write_pep610_url_references_for_cached_package( def test_executor_should_write_pep610_url_references_for_files( - tmp_venv: VirtualEnv, pool: Pool, config: Config, io: BufferedIO + tmp_venv: VirtualEnv, pool: RepositoryPool, config: Config, io: BufferedIO ): url = ( Path(__file__) @@ -523,7 +539,7 @@ def test_executor_should_write_pep610_url_references_for_files( def test_executor_should_write_pep610_url_references_for_directories( - tmp_venv: VirtualEnv, pool: Pool, config: Config, io: BufferedIO + tmp_venv: VirtualEnv, pool: RepositoryPool, config: Config, io: BufferedIO ): url = Path(__file__).parent.parent.joinpath("fixtures/simple_project").resolve() package = Package( @@ -538,7 +554,7 @@ def test_executor_should_write_pep610_url_references_for_directories( def test_executor_should_write_pep610_url_references_for_editable_directories( - tmp_venv: VirtualEnv, pool: Pool, config: Config, io: BufferedIO + tmp_venv: VirtualEnv, pool: RepositoryPool, config: Config, io: BufferedIO ): url = Path(__file__).parent.parent.joinpath("fixtures/simple_project").resolve() package = Package( @@ -558,7 +574,7 @@ def test_executor_should_write_pep610_url_references_for_editable_directories( def test_executor_should_write_pep610_url_references_for_urls( tmp_venv: VirtualEnv, - pool: Pool, + pool: RepositoryPool, config: Config, io: BufferedIO, mock_file_downloads: None, @@ -579,7 +595,7 @@ def test_executor_should_write_pep610_url_references_for_urls( def test_executor_should_write_pep610_url_references_for_git( tmp_venv: VirtualEnv, - pool: Pool, + pool: RepositoryPool, config: Config, io: BufferedIO, mock_file_downloads: None, @@ -611,7 +627,7 @@ def test_executor_should_write_pep610_url_references_for_git( def test_executor_should_write_pep610_url_references_for_git_with_subdirectories( tmp_venv: VirtualEnv, - pool: Pool, + pool: RepositoryPool, config: Config, io: BufferedIO, mock_file_downloads: None, @@ -645,7 +661,7 @@ def test_executor_should_write_pep610_url_references_for_git_with_subdirectories def test_executor_should_use_cached_link_and_hash( tmp_venv: VirtualEnv, - pool: Pool, + pool: RepositoryPool, config: Config, io: BufferedIO, mocker: MockerFixture, @@ -688,7 +704,7 @@ def test_executor_should_use_cached_link_and_hash( ) def test_executor_should_be_initialized_with_correct_workers( tmp_venv: VirtualEnv, - pool: Pool, + pool: RepositoryPool, config: Config, io: BufferedIO, mocker: MockerFixture, @@ -709,7 +725,7 @@ def test_executor_should_be_initialized_with_correct_workers( def test_executer_fallback_on_poetry_create_error( mocker: MockerFixture, config: Config, - pool: Pool, + pool: RepositoryPool, io: BufferedIO, tmp_dir: str, mock_file_downloads: None, diff --git a/tests/installation/test_installer.py b/tests/installation/test_installer.py index f7fd6213c58..ed3f54b532e 100644 --- a/tests/installation/test_installer.py +++ b/tests/installation/test_installer.py @@ -25,8 +25,8 @@ from poetry.installation.executor import Executor as BaseExecutor from poetry.installation.noop_installer import NoopInstaller from poetry.packages import Locker as BaseLocker -from poetry.repositories import Pool from poetry.repositories import Repository +from poetry.repositories import RepositoryPool from poetry.repositories.installed_repository import InstalledRepository from poetry.utils.env import MockEnv from poetry.utils.env import NullEnv @@ -156,8 +156,8 @@ def repo() -> Repository: @pytest.fixture() -def pool(repo: Repository) -> Pool: - pool = Pool() +def pool(repo: Repository) -> RepositoryPool: + pool = RepositoryPool() pool.add_repository(repo) return pool @@ -181,7 +181,7 @@ def env() -> NullEnv: @pytest.fixture() def installer( package: ProjectPackage, - pool: Pool, + pool: RepositoryPool, locker: Locker, env: NullEnv, installed: CustomInstalledRepository, @@ -1152,7 +1152,7 @@ def test_installer_with_pypi_repository( installed: CustomInstalledRepository, config: Config, ): - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockRepository()) installer = Installer( @@ -1911,7 +1911,7 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de package: ProjectPackage, installed: CustomInstalledRepository, env: NullEnv, - pool: Pool, + pool: RepositoryPool, config: Config, ): package.add_dependency(Factory.create_dependency("A", {"version": "^1.0"})) @@ -1982,7 +1982,7 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de ): mocker.patch("sys.platform", "darwin") - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockRepository()) installer = Installer( @@ -2043,7 +2043,7 @@ def test_installer_required_extras_should_be_installed( env: NullEnv, config: Config, ): - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockRepository()) installer = Installer( @@ -2185,7 +2185,7 @@ def test_installer_can_install_dependencies_from_forced_source( Factory.create_dependency("tomlkit", {"version": "^0.5", "source": "legacy"}) ) - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockLegacyRepository()) pool.add_repository(MockRepository()) @@ -2228,7 +2228,7 @@ def test_run_installs_with_url_file( @pytest.mark.parametrize("env_platform", ["linux", "win32"]) def test_run_installs_with_same_version_url_files( - pool: Pool, + pool: RepositoryPool, locker: Locker, installed: CustomInstalledRepository, config: Config, @@ -2313,7 +2313,7 @@ def test_installer_can_handle_old_lock_files( installed: CustomInstalledRepository, config: Config, ): - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockRepository()) package.add_dependency(Factory.create_dependency("pytest", "^3.5", groups=["dev"])) diff --git a/tests/installation/test_installer_old.py b/tests/installation/test_installer_old.py index 3c7fe7f2e6f..26dd19f6925 100644 --- a/tests/installation/test_installer_old.py +++ b/tests/installation/test_installer_old.py @@ -15,8 +15,8 @@ from poetry.installation import Installer as BaseInstaller from poetry.installation.noop_installer import NoopInstaller from poetry.packages import Locker as BaseLocker -from poetry.repositories import Pool from poetry.repositories import Repository +from poetry.repositories import RepositoryPool from poetry.repositories.installed_repository import InstalledRepository from poetry.utils.env import MockEnv from poetry.utils.env import NullEnv @@ -108,8 +108,8 @@ def repo() -> Repository: @pytest.fixture() -def pool(repo: Repository) -> Pool: - pool = Pool() +def pool(repo: Repository) -> RepositoryPool: + pool = RepositoryPool() pool.add_repository(repo) return pool @@ -133,7 +133,7 @@ def env() -> NullEnv: @pytest.fixture() def installer( package: ProjectPackage, - pool: Pool, + pool: RepositoryPool, locker: Locker, env: NullEnv, installed: CustomInstalledRepository, @@ -820,7 +820,7 @@ def test_installer_with_pypi_repository( installed: CustomInstalledRepository, config: Config, ): - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockRepository()) installer = Installer( @@ -1567,7 +1567,7 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de package: ProjectPackage, installed: CustomInstalledRepository, env: NullEnv, - pool: Pool, + pool: RepositoryPool, config: Config, ): package.add_dependency(Factory.create_dependency("A", {"version": "^1.0"})) @@ -1630,7 +1630,7 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de ): mocker.patch("sys.platform", "darwin") - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockRepository()) installer = Installer( @@ -1675,7 +1675,7 @@ def test_installer_required_extras_should_be_installed( env: NullEnv, config: Config, ): - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockRepository()) installer = Installer( @@ -1801,7 +1801,7 @@ def test_installer_can_install_dependencies_from_forced_source( Factory.create_dependency("tomlkit", {"version": "^0.5", "source": "legacy"}) ) - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockLegacyRepository()) pool.add_repository(MockRepository()) @@ -1871,7 +1871,7 @@ def test_installer_can_handle_old_lock_files( installed: CustomInstalledRepository, config: Config, ): - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockRepository()) package.add_dependency(Factory.create_dependency("pytest", "^3.5", groups=["dev"])) diff --git a/tests/installation/test_pip_installer.py b/tests/installation/test_pip_installer.py index eab8303cba3..117a45d40db 100644 --- a/tests/installation/test_pip_installer.py +++ b/tests/installation/test_pip_installer.py @@ -13,7 +13,7 @@ from poetry.installation.pip_installer import PipInstaller from poetry.repositories.legacy_repository import LegacyRepository -from poetry.repositories.pool import Pool +from poetry.repositories.repository_pool import RepositoryPool from poetry.utils.authenticator import RepositoryCertificateConfig from poetry.utils.env import NullEnv @@ -53,12 +53,12 @@ def package_git_with_subdirectory() -> Package: @pytest.fixture -def pool() -> Pool: - return Pool() +def pool() -> RepositoryPool: + return RepositoryPool() @pytest.fixture -def installer(pool: Pool) -> PipInstaller: +def installer(pool: RepositoryPool) -> PipInstaller: return PipInstaller(NullEnv(), NullIO(), pool) @@ -84,7 +84,7 @@ def test_requirement(installer: PipInstaller): def test_requirement_source_type_url(): - installer = PipInstaller(NullEnv(), NullIO(), Pool()) + installer = PipInstaller(NullEnv(), NullIO(), RepositoryPool()) foo = Package( "foo", @@ -100,7 +100,7 @@ def test_requirement_source_type_url(): def test_requirement_git_subdirectory( - pool: Pool, package_git_with_subdirectory: Package + pool: RepositoryPool, package_git_with_subdirectory: Package ) -> None: null_env = NullEnv() installer = PipInstaller(null_env, NullIO(), pool) @@ -125,7 +125,9 @@ def test_requirement_git_develop_false(installer: PipInstaller, package_git: Pac assert result == expected -def test_install_with_non_pypi_default_repository(pool: Pool, installer: PipInstaller): +def test_install_with_non_pypi_default_repository( + pool: RepositoryPool, installer: PipInstaller +): default = LegacyRepository("default", "https://default.com") another = LegacyRepository("another", "https://another.com") @@ -166,7 +168,7 @@ def test_install_with_certs(mocker: MockerFixture, key: str, option: str): ) default = LegacyRepository("default", "https://foo.bar") - pool = Pool() + pool = RepositoryPool() pool.add_repository(default, default=True) null_env = NullEnv() @@ -200,7 +202,7 @@ def test_requirement_git_develop_true(installer: PipInstaller, package_git: Pack def test_uninstall_git_package_nspkg_pth_cleanup( - mocker: MockerFixture, tmp_venv: VirtualEnv, pool: Pool + mocker: MockerFixture, tmp_venv: VirtualEnv, pool: RepositoryPool ): # this test scenario requires a real installation using the pip installer installer = PipInstaller(tmp_venv, NullIO(), pool) @@ -244,7 +246,7 @@ def test_install_with_trusted_host(config: Config): config.merge({"certificates": {"default": {"cert": False}}}) default = LegacyRepository("default", "https://foo.bar") - pool = Pool() + pool = RepositoryPool() pool.add_repository(default, default=True) null_env = NullEnv() @@ -269,7 +271,7 @@ def test_install_with_trusted_host(config: Config): def test_install_directory_fallback_on_poetry_create_error( - mocker: MockerFixture, tmp_venv: VirtualEnv, pool: Pool + mocker: MockerFixture, tmp_venv: VirtualEnv, pool: RepositoryPool ): mock_create_poetry = mocker.patch( "poetry.factory.Factory.create_poetry", side_effect=RuntimeError diff --git a/tests/mixology/version_solver/conftest.py b/tests/mixology/version_solver/conftest.py index 453cc004399..33bb6a3a724 100644 --- a/tests/mixology/version_solver/conftest.py +++ b/tests/mixology/version_solver/conftest.py @@ -8,8 +8,8 @@ from poetry.core.packages.project_package import ProjectPackage from poetry.puzzle.provider import Provider as BaseProvider -from poetry.repositories import Pool from poetry.repositories import Repository +from poetry.repositories import RepositoryPool if TYPE_CHECKING: @@ -28,8 +28,8 @@ def repo() -> Repository: @pytest.fixture -def pool(repo: TestRepository) -> Pool: - pool = Pool() +def pool(repo: TestRepository) -> RepositoryPool: + pool = RepositoryPool() pool.add_repository(repo) return pool @@ -41,5 +41,5 @@ def root() -> ProjectPackage: @pytest.fixture -def provider(pool: Pool, root: ProjectPackage) -> Provider: +def provider(pool: RepositoryPool, root: ProjectPackage) -> Provider: return Provider(root, pool, NullIO()) diff --git a/tests/mixology/version_solver/test_with_lock.py b/tests/mixology/version_solver/test_with_lock.py index caa7790f856..79f428491ae 100644 --- a/tests/mixology/version_solver/test_with_lock.py +++ b/tests/mixology/version_solver/test_with_lock.py @@ -16,12 +16,12 @@ if TYPE_CHECKING: from poetry.core.packages.project_package import ProjectPackage - from poetry.repositories import Pool from poetry.repositories import Repository + from poetry.repositories import RepositoryPool def test_with_compatible_locked_dependencies( - root: ProjectPackage, repo: Repository, pool: Pool + root: ProjectPackage, repo: Repository, pool: RepositoryPool ): root.add_dependency(Factory.create_dependency("foo", "*")) @@ -43,7 +43,7 @@ def test_with_compatible_locked_dependencies( def test_with_incompatible_locked_dependencies( - root: ProjectPackage, repo: Repository, pool: Pool + root: ProjectPackage, repo: Repository, pool: RepositoryPool ): root.add_dependency(Factory.create_dependency("foo", ">1.0.1")) @@ -65,7 +65,7 @@ def test_with_incompatible_locked_dependencies( def test_with_unrelated_locked_dependencies( - root: ProjectPackage, repo: Repository, pool: Pool + root: ProjectPackage, repo: Repository, pool: RepositoryPool ): root.add_dependency(Factory.create_dependency("foo", "*")) @@ -88,7 +88,7 @@ def test_with_unrelated_locked_dependencies( def test_unlocks_dependencies_if_necessary_to_ensure_that_a_new_dependency_is_satisfied( - root: ProjectPackage, repo: Repository, pool: Pool + root: ProjectPackage, repo: Repository, pool: RepositoryPool ): root.add_dependency(Factory.create_dependency("foo", "*")) root.add_dependency(Factory.create_dependency("newdep", "2.0.0")) @@ -125,7 +125,7 @@ def test_unlocks_dependencies_if_necessary_to_ensure_that_a_new_dependency_is_sa def test_with_compatible_locked_dependencies_use_latest( - root: ProjectPackage, repo: Repository, pool: Pool + root: ProjectPackage, repo: Repository, pool: RepositoryPool ): root.add_dependency(Factory.create_dependency("foo", "*")) root.add_dependency(Factory.create_dependency("baz", "*")) @@ -155,7 +155,7 @@ def test_with_compatible_locked_dependencies_use_latest( def test_with_compatible_locked_dependencies_with_extras( - root: ProjectPackage, repo: Repository, pool: Pool + root: ProjectPackage, repo: Repository, pool: RepositoryPool ): root.add_dependency(Factory.create_dependency("foo", "^1.0")) @@ -189,7 +189,7 @@ def test_with_compatible_locked_dependencies_with_extras( def test_with_yanked_package_in_lock( - root: ProjectPackage, repo: Repository, pool: Pool + root: ProjectPackage, repo: Repository, pool: RepositoryPool ): root.add_dependency(Factory.create_dependency("foo", "*")) @@ -218,7 +218,7 @@ def test_with_yanked_package_in_lock( def test_no_update_is_respected_for_legacy_repository( - root: ProjectPackage, repo: Repository, pool: Pool + root: ProjectPackage, repo: Repository, pool: RepositoryPool ): root.add_dependency(Factory.create_dependency("foo", "^1.0")) diff --git a/tests/puzzle/test_provider.py b/tests/puzzle/test_provider.py index 753a0fcbcb4..a5126a47337 100644 --- a/tests/puzzle/test_provider.py +++ b/tests/puzzle/test_provider.py @@ -19,8 +19,8 @@ from poetry.inspection.info import PackageInfo from poetry.packages import DependencyPackage from poetry.puzzle.provider import Provider -from poetry.repositories.pool import Pool from poetry.repositories.repository import Repository +from poetry.repositories.repository_pool import RepositoryPool from poetry.utils.env import EnvCommandError from poetry.utils.env import MockEnv as BaseMockEnv from tests.helpers import get_dependency @@ -49,15 +49,15 @@ def repository() -> Repository: @pytest.fixture -def pool(repository: Repository) -> Pool: - pool = Pool() +def pool(repository: Repository) -> RepositoryPool: + pool = RepositoryPool() pool.add_repository(repository) return pool @pytest.fixture -def provider(root: ProjectPackage, pool: Pool) -> Provider: +def provider(root: ProjectPackage, pool: RepositoryPool) -> Provider: return Provider(root, pool, NullIO()) diff --git a/tests/puzzle/test_solver.py b/tests/puzzle/test_solver.py index 601151eab16..d55ea5b2915 100644 --- a/tests/puzzle/test_solver.py +++ b/tests/puzzle/test_solver.py @@ -19,8 +19,8 @@ from poetry.packages import DependencyPackage from poetry.puzzle import Solver from poetry.puzzle.exceptions import SolverProblemError -from poetry.repositories.pool import Pool from poetry.repositories.repository import Repository +from poetry.repositories.repository_pool import RepositoryPool from poetry.utils.env import MockEnv from tests.helpers import MOCK_DEFAULT_GIT_REVISION from tests.helpers import get_dependency @@ -67,12 +67,12 @@ def repo() -> Repository: @pytest.fixture() -def pool(repo: Repository) -> Pool: - return Pool([repo]) +def pool(repo: Repository) -> RepositoryPool: + return RepositoryPool([repo]) @pytest.fixture() -def solver(package: ProjectPackage, pool: Pool, io: NullIO) -> Solver: +def solver(package: ProjectPackage, pool: RepositoryPool, io: NullIO) -> Solver: return Solver(package, pool, [], [], io) @@ -123,7 +123,7 @@ def test_solver_install_single( def test_solver_remove_if_no_longer_locked( - package: ProjectPackage, pool: Pool, io: NullIO + package: ProjectPackage, pool: RepositoryPool, io: NullIO ): package_a = get_package("A", "1.0") @@ -134,7 +134,7 @@ def test_solver_remove_if_no_longer_locked( def test_remove_non_installed( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): package_a = get_package("A", "1.0") repo.add_package(package_a) @@ -158,7 +158,7 @@ def test_install_non_existing_package_fail( def test_install_unpublished_package_does_not_fail( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): package.add_dependency(Factory.create_dependency("B", "1")) @@ -270,7 +270,7 @@ def test_install_with_deps_in_order( def test_install_installed( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): package.add_dependency(Factory.create_dependency("A", "*")) @@ -286,7 +286,7 @@ def test_install_installed( def test_update_installed( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): package.add_dependency(Factory.create_dependency("A", "*")) @@ -304,7 +304,7 @@ def test_update_installed( def test_update_with_use_latest( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): package.add_dependency(Factory.create_dependency("A", "*")) package.add_dependency(Factory.create_dependency("B", "*")) @@ -757,7 +757,7 @@ def test_solver_finds_extras_next_to_non_extras( def test_solver_merge_extras_into_base_package_multiple_repos_fixes_5727( - solver: Solver, repo: Repository, pool: Pool, package: ProjectPackage + solver: Solver, repo: Repository, pool: RepositoryPool, package: ProjectPackage ): package.add_dependency( Factory.create_dependency("A", {"version": "*", "source": "legacy"}) @@ -2094,7 +2094,7 @@ def test_solver_ignores_dependencies_with_incompatible_python_full_version_marke def test_solver_git_dependencies_update( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): pendulum = get_package("pendulum", "2.0.3") cleo = get_package("cleo", "1.0.0") @@ -2143,7 +2143,7 @@ def test_solver_git_dependencies_update( def test_solver_git_dependencies_update_skipped( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): pendulum = get_package("pendulum", "2.0.3") cleo = get_package("cleo", "1.0.0") @@ -2176,7 +2176,7 @@ def test_solver_git_dependencies_update_skipped( def test_solver_git_dependencies_short_hash_update_skipped( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): pendulum = get_package("pendulum", "2.0.3") cleo = get_package("cleo", "1.0.0") @@ -2257,7 +2257,7 @@ def test_solver_can_resolve_directory_dependencies( def test_solver_can_resolve_directory_dependencies_nested_editable( repo: Repository, - pool: Pool, + pool: RepositoryPool, io: NullIO, ): base = Path(__file__).parent.parent / "fixtures" / "project_with_nested_local" @@ -2499,7 +2499,7 @@ def test_solver_can_solve_with_legacy_repository_using_proper_dists( package: ProjectPackage, io: NullIO ): repo = MockLegacyRepository() - pool = Pool([repo]) + pool = RepositoryPool([repo]) solver = Solver(package, pool, [], [], io) @@ -2544,7 +2544,7 @@ def test_solver_can_solve_with_legacy_repository_using_proper_python_compatible_ package.python_versions = "^3.7" repo = MockLegacyRepository() - pool = Pool([repo]) + pool = RepositoryPool([repo]) solver = Solver(package, pool, [], [], io) @@ -2573,7 +2573,7 @@ def test_solver_skips_invalid_versions(package: ProjectPackage, io: NullIO): package.python_versions = "^3.7" repo = MockPyPIRepository() - pool = Pool([repo]) + pool = RepositoryPool([repo]) solver = Solver(package, pool, [], [], io) @@ -2617,7 +2617,7 @@ def test_solver_chooses_most_recent_version_amongst_repositories( package.add_dependency(Factory.create_dependency("tomlkit", {"version": "^0.5"})) repo = MockLegacyRepository() - pool = Pool([repo, MockPyPIRepository()]) + pool = RepositoryPool([repo, MockPyPIRepository()]) solver = Solver(package, pool, [], [], io) @@ -2640,7 +2640,7 @@ def test_solver_chooses_from_correct_repository_if_forced( ) repo = MockLegacyRepository() - pool = Pool([repo, MockPyPIRepository()]) + pool = RepositoryPool([repo, MockPyPIRepository()]) solver = Solver(package, pool, [], [], io) @@ -2679,7 +2679,7 @@ def test_solver_chooses_from_correct_repository_if_forced_and_transitive_depende foo = get_package("foo", "1.0.0") foo.add_dependency(Factory.create_dependency("tomlkit", "^0.5.0")) repo.add_package(foo) - pool = Pool([MockLegacyRepository(), repo, MockPyPIRepository()]) + pool = RepositoryPool([MockLegacyRepository(), repo, MockPyPIRepository()]) solver = Solver(package, pool, [], [], io) @@ -2714,7 +2714,7 @@ def test_solver_does_not_choose_from_secondary_repository_by_default( package.python_versions = "^3.7" package.add_dependency(Factory.create_dependency("clikit", {"version": "^0.2.0"})) - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockPyPIRepository(), secondary=True) pool.add_repository(MockLegacyRepository()) @@ -2764,7 +2764,7 @@ def test_solver_chooses_from_secondary_if_explicit( Factory.create_dependency("clikit", {"version": "^0.2.0", "source": "PyPI"}) ) - pool = Pool() + pool = RepositoryPool() pool.add_repository(MockPyPIRepository(), secondary=True) pool.add_repository(MockLegacyRepository()) @@ -2800,7 +2800,7 @@ def test_solver_chooses_from_secondary_if_explicit( def test_solver_discards_packages_with_empty_markers( package: ProjectPackage, repo: Repository, - pool: Pool, + pool: RepositoryPool, io: NullIO, ): package.python_versions = "~2.7 || ^3.4" @@ -2902,7 +2902,7 @@ def test_solver_does_not_loop_indefinitely_on_duplicate_constraints_with_extras( def test_solver_does_not_fail_with_locked_git_and_non_git_dependencies( package: ProjectPackage, repo: Repository, - pool: Pool, + pool: RepositoryPool, io: NullIO, ): package.add_dependency( @@ -2995,7 +2995,9 @@ def test_solver_should_not_go_into_an_infinite_loop_on_duplicate_dependencies( ) -def test_solver_synchronize_single(package: ProjectPackage, pool: Pool, io: NullIO): +def test_solver_synchronize_single( + package: ProjectPackage, pool: RepositoryPool, io: NullIO +): package_a = get_package("a", "1.0") solver = Solver(package, pool, [package_a], [], io) @@ -3009,7 +3011,7 @@ def test_solver_synchronize_single(package: ProjectPackage, pool: Pool, io: Null @pytest.mark.skip(reason="Poetry no longer has critical package requirements") def test_solver_with_synchronization_keeps_critical_package( package: ProjectPackage, - pool: Pool, + pool: RepositoryPool, io: NullIO, ): package_pip = get_package("setuptools", "1.0") @@ -3140,7 +3142,7 @@ def test_solver_cannot_choose_another_version_for_url_dependencies( def test_solver_should_not_update_same_version_packages_if_installed_has_no_source_type( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): package.add_dependency(Factory.create_dependency("foo", "1.0.0")) @@ -3330,7 +3332,7 @@ def test_solver_can_resolve_for_packages_with_missing_extras( def test_solver_can_resolve_python_restricted_package_dependencies( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): package.add_dependency( Factory.create_dependency("futures", {"version": "^3.3.0", "python": "~2.7"}) @@ -3414,7 +3416,7 @@ def test_solver_should_not_raise_errors_for_irrelevant_transitive_python_constra def test_solver_keeps_multiple_locked_dependencies_for_same_package( package: ProjectPackage, repo: Repository, - pool: Pool, + pool: RepositoryPool, io: NullIO, is_locked: bool, ): @@ -3468,7 +3470,7 @@ def test_solver_keeps_multiple_locked_dependencies_for_same_package( def test_solver_does_not_update_ref_of_locked_vcs_package( package: ProjectPackage, repo: Repository, - pool: Pool, + pool: RepositoryPool, io: NullIO, is_locked: bool, ): @@ -3524,7 +3526,7 @@ def test_solver_does_not_update_ref_of_locked_vcs_package( def test_solver_does_not_fetch_locked_vcs_package_with_ref( package: ProjectPackage, repo: Repository, - pool: Pool, + pool: RepositoryPool, io: NullIO, mocker: MockerFixture, ): @@ -3660,7 +3662,7 @@ def test_solver_incompatible_dependency_with_and_without_extras( def test_update_with_prerelease_and_no_solution( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO + package: ProjectPackage, repo: Repository, pool: RepositoryPool, io: NullIO ): # Locked and installed: cleo which depends on an old version of crashtest. cleo = get_package("cleo", "1.0.0a5") @@ -3689,7 +3691,7 @@ def test_update_with_prerelease_and_no_solution( def test_solver_yanked_warning( package: ProjectPackage, - pool: Pool, + pool: RepositoryPool, repo: Repository, ) -> None: package.add_dependency(Factory.create_dependency("foo", "==1")) @@ -3728,7 +3730,11 @@ def test_solver_yanked_warning( @pytest.mark.parametrize("is_locked", [False, True]) def test_update_with_use_latest_vs_lock( - package: ProjectPackage, repo: Repository, pool: Pool, io: NullIO, is_locked: bool + package: ProjectPackage, + repo: Repository, + pool: RepositoryPool, + io: NullIO, + is_locked: bool, ): """ A1 depends on B2, A2 and A3 depend on B1. Same for C. diff --git a/tests/repositories/test_pool.py b/tests/repositories/test_repository_pool.py similarity index 91% rename from tests/repositories/test_pool.py rename to tests/repositories/test_repository_pool.py index dc68bf0015b..ccc0e269224 100644 --- a/tests/repositories/test_pool.py +++ b/tests/repositories/test_repository_pool.py @@ -4,8 +4,8 @@ from poetry.core.constraints.version import Version -from poetry.repositories import Pool from poetry.repositories import Repository +from poetry.repositories import RepositoryPool from poetry.repositories.exceptions import PackageNotFound from poetry.repositories.legacy_repository import LegacyRepository from tests.helpers import get_dependency @@ -13,7 +13,7 @@ def test_pool() -> None: - pool = Pool() + pool = RepositoryPool() assert len(pool.repositories) == 0 assert not pool.has_default() @@ -22,7 +22,7 @@ def test_pool() -> None: def test_pool_with_initial_repositories() -> None: repo = Repository("repo") - pool = Pool([repo]) + pool = RepositoryPool([repo]) assert len(pool.repositories) == 1 assert not pool.has_default() @@ -30,7 +30,7 @@ def test_pool_with_initial_repositories() -> None: def test_repository_no_repository() -> None: - pool = Pool() + pool = RepositoryPool() with pytest.raises(IndexError): pool.repository("foo") @@ -41,15 +41,15 @@ def test_adding_repositories_with_same_name_twice_raises_value_error() -> None: repo2 = Repository("repo") with pytest.raises(ValueError): - Pool([repo1, repo2]) + RepositoryPool([repo1, repo2]) with pytest.raises(ValueError): - Pool([repo1]).add_repository(repo2) + RepositoryPool([repo1]).add_repository(repo2) def test_repository_from_normal_pool() -> None: repo = LegacyRepository("foo", "https://foo.bar") - pool = Pool() + pool = RepositoryPool() pool.add_repository(repo) assert pool.repository("foo") is repo @@ -57,7 +57,7 @@ def test_repository_from_normal_pool() -> None: def test_repository_from_secondary_pool() -> None: repo = LegacyRepository("foo", "https://foo.bar") - pool = Pool() + pool = RepositoryPool() pool.add_repository(repo, secondary=True) assert pool.repository("foo") is repo @@ -69,7 +69,7 @@ def test_repository_with_normal_default_and_secondary_repositories() -> None: repo1 = LegacyRepository("foo", "https://foo.bar") repo2 = LegacyRepository("bar", "https://bar.baz") - pool = Pool() + pool = RepositoryPool() pool.add_repository(repo1) pool.add_repository(secondary, secondary=True) pool.add_repository(repo2) @@ -84,7 +84,7 @@ def test_repository_with_normal_default_and_secondary_repositories() -> None: def test_remove_non_existing_repository_raises_indexerror() -> None: - pool = Pool() + pool = RepositoryPool() with pytest.raises(IndexError): pool.remove_repository("foo") @@ -95,7 +95,7 @@ def test_remove_existing_repository_successful() -> None: repo2 = LegacyRepository("bar", "https://bar.baz") repo3 = LegacyRepository("baz", "https://baz.quux") - pool = Pool() + pool = RepositoryPool() pool.add_repository(repo1) pool.add_repository(repo2) pool.add_repository(repo3) @@ -112,7 +112,7 @@ def test_remove_default_repository() -> None: repo2 = LegacyRepository("bar", "https://bar.baz") new_default = LegacyRepository("new_default", "https://new.default.com") - pool = Pool() + pool = RepositoryPool() pool.add_repository(repo1) pool.add_repository(repo2) pool.add_repository(default, default=True) @@ -140,7 +140,7 @@ def test_repository_ordering() -> None: secondary2 = LegacyRepository("secondary2", "https://secondary2.com") secondary3 = LegacyRepository("secondary3", "https://secondary3.com") - pool = Pool() + pool = RepositoryPool() pool.add_repository(secondary1, secondary=True) pool.add_repository(primary1) pool.add_repository(default1, default=True) @@ -163,7 +163,7 @@ def test_pool_get_package_in_any_repository() -> None: repo1 = Repository("repo1", [package1]) package2 = get_package("bar", "1.0.0") repo2 = Repository("repo2", [package1, package2]) - pool = Pool([repo1, repo2]) + pool = RepositoryPool([repo1, repo2]) returned_package1 = pool.package("foo", Version.parse("1.0.0")) returned_package2 = pool.package("bar", Version.parse("1.0.0")) @@ -176,7 +176,7 @@ def test_pool_get_package_in_specified_repository() -> None: package = get_package("foo", "1.0.0") repo1 = Repository("repo1") repo2 = Repository("repo2", [package]) - pool = Pool([repo1, repo2]) + pool = RepositoryPool([repo1, repo2]) returned_package = pool.package( "foo", Version.parse("1.0.0"), repository_name="repo2" @@ -186,7 +186,7 @@ def test_pool_get_package_in_specified_repository() -> None: def test_pool_no_package_from_any_repository_raises_package_not_found() -> None: - pool = Pool() + pool = RepositoryPool() pool.add_repository(Repository("repo")) with pytest.raises(PackageNotFound): @@ -197,7 +197,7 @@ def test_pool_no_package_from_specified_repository_raises_package_not_found() -> package = get_package("foo", "1.0.0") repo1 = Repository("repo1") repo2 = Repository("repo2", [package]) - pool = Pool([repo1, repo2]) + pool = RepositoryPool([repo1, repo2]) with pytest.raises(PackageNotFound): pool.package("foo", Version.parse("1.0.0"), repository_name="repo1") @@ -210,7 +210,7 @@ def test_pool_find_packages_in_any_repository() -> None: package4 = get_package("bar", "1.2.3") repo1 = Repository("repo1", [package1, package3]) repo2 = Repository("repo2", [package1, package2, package4]) - pool = Pool([repo1, repo2]) + pool = RepositoryPool([repo1, repo2]) available_dependency = get_dependency("foo", "^1.0.0") returned_packages_available = pool.find_packages(available_dependency) @@ -228,7 +228,7 @@ def test_pool_find_packages_in_specified_repository() -> None: package_bar = get_package("bar", "1.2.3") repo1 = Repository("repo1", [package_foo1, package_foo3]) repo2 = Repository("repo2", [package_foo1, package_foo2, package_bar]) - pool = Pool([repo1, repo2]) + pool = RepositoryPool([repo1, repo2]) available_dependency = get_dependency("foo", "^1.0.0") available_dependency.source_name = "repo2" @@ -247,7 +247,7 @@ def test_search_no_legacy_repositories() -> None: package_foobar = get_package("foobar", "1.0.0") repo1 = Repository("repo1", [package_foo1, package_foo2]) repo2 = Repository("repo2", [package_foo1, package_foobar]) - pool = Pool([repo1, repo2]) + pool = RepositoryPool([repo1, repo2]) assert pool.search("foo") == [ package_foo1, @@ -263,6 +263,6 @@ def test_search_legacy_repositories_are_skipped() -> None: package = get_package("foo", "1.0.0") repo1 = Repository("repo1", [package]) repo2 = LegacyRepository("repo2", "https://fake.repo/") - pool = Pool([repo1, repo2]) + pool = RepositoryPool([repo1, repo2]) assert pool.search("foo") == [package] From 2d512d53b5e2495129bb1f81054634b0622425eb Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Sat, 15 Oct 2022 22:25:40 +0200 Subject: [PATCH 6/6] refactor: deprecate poetry.repositories.pool --- src/poetry/repositories/__init__.py | 3 ++- src/poetry/repositories/pool.py | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/poetry/repositories/pool.py diff --git a/src/poetry/repositories/__init__.py b/src/poetry/repositories/__init__.py index d923a9691aa..78c59562ab8 100644 --- a/src/poetry/repositories/__init__.py +++ b/src/poetry/repositories/__init__.py @@ -1,7 +1,8 @@ from __future__ import annotations +from poetry.repositories.pool import Pool from poetry.repositories.repository import Repository from poetry.repositories.repository_pool import RepositoryPool -__all__ = ["Repository", "RepositoryPool"] +__all__ = ["Pool", "Repository", "RepositoryPool"] diff --git a/src/poetry/repositories/pool.py b/src/poetry/repositories/pool.py new file mode 100644 index 00000000000..5f67f1768a5 --- /dev/null +++ b/src/poetry/repositories/pool.py @@ -0,0 +1,27 @@ +from __future__ import annotations + +import warnings + +from typing import TYPE_CHECKING + +from poetry.repositories.repository_pool import RepositoryPool + + +if TYPE_CHECKING: + from poetry.repositories.repository import Repository + + +class Pool(RepositoryPool): + def __init__( + self, + repositories: list[Repository] | None = None, + ignore_repository_names: bool = False, + ) -> None: + warnings.warn( + "Object Pool from poetry.repositories.pool is renamed and scheduled for" + " removal in poetry release 1.4.0. Please migrate to RepositoryPool from" + " poetry.repositories.repository_pool.", + DeprecationWarning, + stacklevel=2, + ) + super().__init__(repositories, ignore_repository_names)