diff --git a/src/poetry/puzzle/provider.py b/src/poetry/puzzle/provider.py index 7b75211cd84..1d2121f916f 100644 --- a/src/poetry/puzzle/provider.py +++ b/src/poetry/puzzle/provider.py @@ -138,7 +138,7 @@ def __init__( self._is_debugging: bool = self._io.is_debug() or self._io.is_very_verbose() self._in_progress = False self._overrides: dict[DependencyPackage, dict[str, Dependency]] = {} - self._deferred_cache: dict[Dependency, Package] = {} + self._deferred_cache: dict[int, Package] = {} self._load_deferred = True self._source_root: Path | None = None self._installed = installed @@ -288,7 +288,7 @@ def search_for_vcs(self, dependency: VCSDependency) -> list[Package]: dependency._source_resolved_reference = package.source_resolved_reference dependency._source_subdirectory = package.source_subdirectory - self._deferred_cache[dependency] = package + self._deferred_cache[hash(dependency)] = package return [package] @@ -315,8 +315,8 @@ def get_package_from_vcs( ) def search_for_file(self, dependency: FileDependency) -> list[Package]: - if dependency in self._deferred_cache: - _package = self._deferred_cache[dependency] + if hash(dependency) in self._deferred_cache: + _package = self._deferred_cache[hash(dependency)] package = _package.clone() else: @@ -325,7 +325,7 @@ def search_for_file(self, dependency: FileDependency) -> list[Package]: dependency._constraint = package.version dependency._pretty_constraint = package.version.text - self._deferred_cache[dependency] = package + self._deferred_cache[hash(dependency)] = package self.validate_package_for_dependency(dependency=dependency, package=package) @@ -352,8 +352,8 @@ def get_package_from_file(cls, file_path: Path) -> Package: return package def search_for_directory(self, dependency: DirectoryDependency) -> list[Package]: - if dependency in self._deferred_cache: - _package = self._deferred_cache[dependency] + if hash(dependency) in self._deferred_cache: + _package = self._deferred_cache[hash(dependency)] package = _package.clone() else: @@ -362,7 +362,7 @@ def search_for_directory(self, dependency: DirectoryDependency) -> list[Package] dependency._constraint = package.version dependency._pretty_constraint = package.version.text - self._deferred_cache[dependency] = package + self._deferred_cache[hash(dependency)] = package self.validate_package_for_dependency(dependency=dependency, package=package) @@ -378,8 +378,8 @@ def get_package_from_directory(cls, directory: Path) -> Package: return PackageInfo.from_directory(path=directory).to_package(root_dir=directory) def search_for_url(self, dependency: URLDependency) -> list[Package]: - if dependency in self._deferred_cache: - return [self._deferred_cache[dependency]] + if hash(dependency) in self._deferred_cache: + return [self._deferred_cache[hash(dependency)]] package = self.get_package_from_url(dependency.url) @@ -396,7 +396,7 @@ def search_for_url(self, dependency: URLDependency) -> list[Package]: dependency._constraint = package.version dependency._pretty_constraint = package.version.text - self._deferred_cache[dependency] = package + self._deferred_cache[hash(dependency)] = package return [package]