diff --git a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb index 6b5d5dab932..e02e9ec65e5 100644 --- a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb @@ -430,6 +430,9 @@ def pip_compile_options_from_compiled_file(requirements_file) options << "--no-header" unless requirements_file.content.include?("autogenerated by pip-c") options << "--pre" if requirements_file.content.include?("--pre") + + options << "--strip-extras" if requirements_file.content.include?("--strip-extras") + options end diff --git a/python/spec/dependabot/python/file_updater/pip_compile_file_updater_spec.rb b/python/spec/dependabot/python/file_updater/pip_compile_file_updater_spec.rb index 3bf187500ba..f65c16340df 100644 --- a/python/spec/dependabot/python/file_updater/pip_compile_file_updater_spec.rb +++ b/python/spec/dependabot/python/file_updater/pip_compile_file_updater_spec.rb @@ -505,5 +505,21 @@ end end end + + context "with stripped extras" do + let(:manifest_fixture_name) { "strip_extras.in" } + let(:generated_fixture_name) { "pip_compile_strip_extras.txt" } + let(:dependency_name) { "cachecontrol" } + let(:dependency_version) { "0.12.10" } + let(:dependency_previous_version) { "0.12.9" } + + it "doesn't add an extras annotation on cachecontrol" do + expect(updated_files.count).to eq(1) + expect(updated_files.first.content).to include("--strip-extras") + expect(updated_files.first.content).to include("cachecontrol==0.12.10") + expect(updated_files.first.content). + to_not include("cachecontrol[filecache]==") + end + end end end diff --git a/python/spec/fixtures/pip_compile_files/strip_extras.in b/python/spec/fixtures/pip_compile_files/strip_extras.in new file mode 100644 index 00000000000..b1db984ed70 --- /dev/null +++ b/python/spec/fixtures/pip_compile_files/strip_extras.in @@ -0,0 +1 @@ +cachecontrol[filecache] diff --git a/python/spec/fixtures/requirements/pip_compile_strip_extras.txt b/python/spec/fixtures/requirements/pip_compile_strip_extras.txt new file mode 100644 index 00000000000..871e3b538b2 --- /dev/null +++ b/python/spec/fixtures/requirements/pip_compile_strip_extras.txt @@ -0,0 +1,22 @@ +# +# This file is autogenerated by pip-compile with python 3.10 +# To update, run: +# +# pip-compile --strip-extras --output-file=constraints.txt constraints.in +# +cachecontrol==0.12.10 + # via -r constraints.in +certifi==2021.10.8 + # via requests +charset-normalizer==2.0.7 + # via requests +idna==3.3 + # via requests +lockfile==0.12.2 + # via cachecontrol +msgpack==1.0.2 + # via cachecontrol +requests==2.26.0 + # via cachecontrol +urllib3==1.26.7 + # via requests