diff --git a/poetry/puzzle/solver.py b/poetry/puzzle/solver.py index aff19ca6813..e9ea1e80658 100644 --- a/poetry/puzzle/solver.py +++ b/poetry/puzzle/solver.py @@ -92,7 +92,7 @@ def solve(self, use_latest=None): # type: (...) -> List[Operation] elif package.version != pkg.version: # Checking version operations.append(Update(pkg, package)) - elif package.source_type != pkg.source_type: + elif pkg.source_type and package.source_type != pkg.source_type: operations.append(Update(pkg, package)) else: operations.append(Install(package).skip("Already installed")) diff --git a/tests/puzzle/test_solver.py b/tests/puzzle/test_solver.py index 1c75b59862f..6ee6fea911f 100644 --- a/tests/puzzle/test_solver.py +++ b/tests/puzzle/test_solver.py @@ -2039,3 +2039,22 @@ def test_solver_cannot_choose_another_version_for_url_dependencies( # via the git dependency with pytest.raises(SolverProblemError): solver.solve() + + +def test_solver_should_not_update_same_version_packages_if_installed_has_no_source_type( + solver, repo, package, installed +): + package.add_dependency("foo", "1.0.0") + + foo = get_package("foo", "1.0.0") + foo.source_type = "legacy" + foo.source_reference = "custom" + foo.source_url = "https://foo.bar" + repo.add_package(foo) + installed.add_package(get_package("foo", "1.0.0")) + + ops = solver.solve() + + check_solver_result( + ops, [{"job": "install", "package": foo, "skipped": True}], + )