diff --git a/python/lib/dependabot/python/file_parser/pyproject_files_parser.rb b/python/lib/dependabot/python/file_parser/pyproject_files_parser.rb index db0c77f3ea8..6ce7ef57e8f 100644 --- a/python/lib/dependabot/python/file_parser/pyproject_files_parser.rb +++ b/python/lib/dependabot/python/file_parser/pyproject_files_parser.rb @@ -27,7 +27,7 @@ def dependency_set dependency_set = Dependabot::FileParsers::Base::DependencySet.new dependency_set += pyproject_dependencies if using_poetry? || using_pep621? - dependency_set += lockfile_dependencies if lockfile + dependency_set += lockfile_dependencies if using_poetry? && lockfile dependency_set end diff --git a/python/spec/dependabot/python/file_parser/pyproject_files_parser_spec.rb b/python/spec/dependabot/python/file_parser/pyproject_files_parser_spec.rb index 0b1caa68ff2..f3f85f7d8b6 100644 --- a/python/spec/dependabot/python/file_parser/pyproject_files_parser_spec.rb +++ b/python/spec/dependabot/python/file_parser/pyproject_files_parser_spec.rb @@ -311,6 +311,23 @@ subject(:dependencies) { parser.dependency_set.dependencies } its(:length) { is_expected.to eq(0) } + + context "and a leftover poetry.lock" do + let(:poetry_lock) do + Dependabot::DependencyFile.new( + name: "poetry.lock", + content: poetry_lock_body + ) + end + let(:poetry_lock_body) do + fixture("poetry_locks", poetry_lock_fixture_name) + end + let(:poetry_lock_fixture_name) { "poetry.lock" } + + let(:files) { [pyproject, pdm_lock, poetry_lock] } + + its(:length) { is_expected.to eq(0) } + end end context "with optional dependencies" do