Skip to content
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

Replace cachecontrol with a fork #7997

Closed
wants to merge 1 commit into from
Closed
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
27 changes: 8 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ python = "^3.8"
poetry-core = "1.6.0"
poetry-plugin-export = "^1.3.1"
build = "^0.10.0"
cachecontrol = { version = "^0.12.9", extras = ["filecache"] }
# cacheyou uses calver, so version is unclamped
cacheyou = { version = ">=23.2", extras = ["filecache"] }
cleo = "^2.0.0"
crashtest = "^0.4.1"
dulwich = "^0.21.2"
filelock = "^3.8.0"
importlib-metadata = { version = ">=4.4", python = "<3.10" }
installer = "^0.7.0"
jsonschema = "^4.10.0"
keyring = "^23.9.0"
lockfile = "^0.12.2"
# packaging uses calver, so version is unclamped
packaging = ">=20.4"
pexpect = "^4.7.0"
Expand Down Expand Up @@ -181,17 +180,14 @@ warn_unused_ignores = false

[[tool.mypy.overrides]]
module = [
'cachecontrol.*',
'deepdiff.*',
'httpretty.*',
'keyring.*',
'lockfile.*',
'pexpect.*',
'requests_toolbelt.*',
'shellingham.*',
'virtualenv.*',
'xattr.*',
'zipp.*',
]
ignore_missing_imports = true

Expand Down
2 changes: 1 addition & 1 deletion src/poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import requests

from cachecontrol.controller import logger as cache_control_logger
from cacheyou.controller import logger as cache_control_logger
from poetry.core.packages.package import Package
from poetry.core.packages.utils.link import Link
from poetry.core.version.exceptions import InvalidVersion
Expand Down
27 changes: 2 additions & 25 deletions src/poetry/utils/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
from typing import TYPE_CHECKING
from typing import Any

import lockfile
import requests
import requests.auth
import requests.exceptions

from cachecontrol import CacheControlAdapter
from cachecontrol.caches import FileCache
from filelock import FileLock
from cacheyou import CacheControlAdapter
from cacheyou.caches import FileCache

from poetry.config.config import Config
from poetry.exceptions import PoetryException
Expand All @@ -37,26 +35,6 @@
logger = logging.getLogger(__name__)


class FileLockLockFile(lockfile.LockBase): # type: ignore[misc]
# The default LockFile from the lockfile package as used by cachecontrol can remain
# locked if a process exits ungracefully. See eg
# <https://github.com/python-poetry/poetry/issues/6030#issuecomment-1189383875>.
#
# FileLock from the filelock package does not have this problem, so we use that to
# construct something compatible with cachecontrol.
def __init__(
self, path: str, threaded: bool = True, timeout: float | None = None
) -> None:
super().__init__(path, threaded, timeout)
self.file_lock = FileLock(self.lock_file)

def acquire(self, timeout: float | None = None) -> None:
self.file_lock.acquire(timeout=timeout)

def release(self) -> None:
self.file_lock.release()


@dataclasses.dataclass(frozen=True)
class RepositoryCertificateConfig:
cert: Path | None = dataclasses.field(default=None)
Expand Down Expand Up @@ -148,7 +126,6 @@ def __init__(
/ (cache_id or "_default_cache")
/ "_http"
),
lock_class=FileLockLockFile,
)
if not disable_cache
else None
Expand Down
2 changes: 1 addition & 1 deletion tests/repositories/test_pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def test_invalid_versions_ignored() -> None:
def test_get_should_invalid_cache_on_too_many_redirects_error(
mocker: MockerFixture,
) -> None:
delete_cache = mocker.patch("cachecontrol.caches.file_cache.FileCache.delete")
delete_cache = mocker.patch("cacheyou.caches.file_cache.FileCache.delete")

response = Response()
response.status_code = 200
Expand Down