From 5bb3e08c80306bbf96682c7799ad90aca36e8e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:45:17 +0100 Subject: [PATCH] fix: do not ignore local config for implicit PyPI source --- src/poetry/factory.py | 6 +++++- src/poetry/repositories/cached_repository.py | 2 +- src/poetry/repositories/http_repository.py | 3 ++- src/poetry/repositories/legacy_repository.py | 9 ++++++++- src/poetry/repositories/pypi_repository.py | 7 ++++++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/poetry/factory.py b/src/poetry/factory.py index e4807aa00c2..d2f6e3f695b 100644 --- a/src/poetry/factory.py +++ b/src/poetry/factory.py @@ -195,7 +195,11 @@ def create_package_source( raise InvalidSourceError( "The PyPI repository cannot be configured with a custom url." ) - return PyPiRepository(disable_cache=disable_cache, pool_size=pool_size) + return PyPiRepository( + config=config, + disable_cache=disable_cache, + pool_size=pool_size, + ) try: url = source["url"] diff --git a/src/poetry/repositories/cached_repository.py b/src/poetry/repositories/cached_repository.py index 1a24477d780..cb5bac13915 100644 --- a/src/poetry/repositories/cached_repository.py +++ b/src/poetry/repositories/cached_repository.py @@ -25,7 +25,7 @@ class CachedRepository(Repository, ABC): CACHE_VERSION = parse_constraint("2.0.0") def __init__( - self, name: str, disable_cache: bool = False, config: Config | None = None + self, name: str, *, disable_cache: bool = False, config: Config | None = None ) -> None: super().__init__(name) self._disable_cache = disable_cache diff --git a/src/poetry/repositories/http_repository.py b/src/poetry/repositories/http_repository.py index 905668e66f0..4548d2f1c49 100644 --- a/src/poetry/repositories/http_repository.py +++ b/src/poetry/repositories/http_repository.py @@ -49,11 +49,12 @@ def __init__( self, name: str, url: str, + *, config: Config | None = None, disable_cache: bool = False, pool_size: int = requests.adapters.DEFAULT_POOLSIZE, ) -> None: - super().__init__(name, disable_cache, config) + super().__init__(name, disable_cache=disable_cache, config=config) self._url = url if config is None: config = Config.create() diff --git a/src/poetry/repositories/legacy_repository.py b/src/poetry/repositories/legacy_repository.py index 5cdcd7cc35f..d8f1e5d2fce 100644 --- a/src/poetry/repositories/legacy_repository.py +++ b/src/poetry/repositories/legacy_repository.py @@ -30,6 +30,7 @@ def __init__( self, name: str, url: str, + *, config: Config | None = None, disable_cache: bool = False, pool_size: int = requests.adapters.DEFAULT_POOLSIZE, @@ -37,7 +38,13 @@ def __init__( if name == "pypi": raise ValueError("The name [pypi] is reserved for repositories") - super().__init__(name, url.rstrip("/"), config, disable_cache, pool_size) + super().__init__( + name, + url.rstrip("/"), + config=config, + disable_cache=disable_cache, + pool_size=pool_size, + ) def package( self, name: str, version: Version, extras: list[str] | None = None diff --git a/src/poetry/repositories/pypi_repository.py b/src/poetry/repositories/pypi_repository.py index 5e47047b1c3..3aa77278373 100644 --- a/src/poetry/repositories/pypi_repository.py +++ b/src/poetry/repositories/pypi_repository.py @@ -29,6 +29,8 @@ from poetry.core.constraints.version import Version from poetry.core.constraints.version import VersionConstraint + from poetry.config.config import Config + SUPPORTED_PACKAGE_TYPES = {"sdist", "bdist_wheel"} @@ -36,13 +38,16 @@ class PyPiRepository(HTTPRepository): def __init__( self, url: str = "https://pypi.org/", + *, + config: Config | None = None, disable_cache: bool = False, - fallback: bool = True, pool_size: int = requests.adapters.DEFAULT_POOLSIZE, + fallback: bool = True, ) -> None: super().__init__( "PyPI", url.rstrip("/") + "/simple/", + config=config, disable_cache=disable_cache, pool_size=pool_size, )