Commit 5cacba89 by Arun Babu Neelicattu

make dependency cache compatible with core 1.1.0a7

This change is required to allow for subdirectories.
parent e1af707a
......@@ -130,6 +130,7 @@ ignore_errors = true
module = [
'poetry.installation.executor',
'poetry.repositories.installed_repository',
'poetry.mixology.version_solver',
]
warn_unused_ignores = false
......
......@@ -19,6 +19,7 @@ from poetry.mixology.result import SolverResult
from poetry.mixology.set_relation import SetRelation
from poetry.mixology.term import Term
from poetry.packages import DependencyPackage
from poetry.utils._compat import metadata
if TYPE_CHECKING:
......@@ -44,7 +45,14 @@ class DependencyCache:
self.cache: dict[
tuple[str, str | None, str | None, str | None], list[DependencyPackage]
] = {}
self.search_for = functools.lru_cache(maxsize=128)(self._search_for)
# TODO: re-enable cache when poetry-core upgrade is completed
self.search_for = functools.lru_cache(
maxsize=128
if metadata.version("poetry-core") # type: ignore[no-untyped-call]
!= "1.1.0a7"
else 0
)(self._search_for)
def _search_for(self, dependency: Dependency) -> list[DependencyPackage]:
key = (
......
......@@ -236,6 +236,7 @@ class Provider:
Basically, we clone the repository in a temporary directory
and get the information we need by checking out the specified reference.
"""
# TODO: remove explicit subdirectory check once poetry-core is updated
# we ensure subdirectory match here as workaround until poetry-core is updated
# to >1.1.0a7
if (
......
......@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING
from poetry.factory import Factory
from poetry.mixology.version_solver import DependencyCache
from tests.compat import is_poetry_core_1_1_0a7_compat
from tests.mixology.helpers import add_to_repo
......@@ -37,8 +38,9 @@ def test_solver_dependency_cache_respects_source_type(
packages_pypi = cache.search_for(dependency_pypi)
packages_git = cache.search_for(dependency_git)
assert cache.search_for.cache_info().hits == 2
assert cache.search_for.cache_info().currsize == 2
if not is_poetry_core_1_1_0a7_compat:
assert cache.search_for.cache_info().hits == 2
assert cache.search_for.cache_info().currsize == 2
assert len(packages_pypi) == len(packages_git) == 1
assert packages_pypi != packages_git
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment