Skip to content

Commit 4af1cd4

Browse files
authored
Merge pull request #4439 from NicolasT/pip-compile-strip-extras
Python: Honour `--strip-extras` flag of `pip-compile`
2 parents 26264e5 + 2cf1980 commit 4af1cd4

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb

+3
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ def pip_compile_options_from_compiled_file(requirements_file)
430430
options << "--no-header" unless requirements_file.content.include?("autogenerated by pip-c")
431431

432432
options << "--pre" if requirements_file.content.include?("--pre")
433+
434+
options << "--strip-extras" if requirements_file.content.include?("--strip-extras")
435+
433436
options
434437
end
435438

python/spec/dependabot/python/file_updater/pip_compile_file_updater_spec.rb

+16
Original file line numberDiff line numberDiff line change
@@ -505,5 +505,21 @@
505505
end
506506
end
507507
end
508+
509+
context "with stripped extras" do
510+
let(:manifest_fixture_name) { "strip_extras.in" }
511+
let(:generated_fixture_name) { "pip_compile_strip_extras.txt" }
512+
let(:dependency_name) { "cachecontrol" }
513+
let(:dependency_version) { "0.12.10" }
514+
let(:dependency_previous_version) { "0.12.9" }
515+
516+
it "doesn't add an extras annotation on cachecontrol" do
517+
expect(updated_files.count).to eq(1)
518+
expect(updated_files.first.content).to include("--strip-extras")
519+
expect(updated_files.first.content).to include("cachecontrol==0.12.10")
520+
expect(updated_files.first.content).
521+
to_not include("cachecontrol[filecache]==")
522+
end
523+
end
508524
end
509525
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cachecontrol[filecache]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# This file is autogenerated by pip-compile with python 3.10
3+
# To update, run:
4+
#
5+
# pip-compile --strip-extras --output-file=constraints.txt constraints.in
6+
#
7+
cachecontrol==0.12.10
8+
# via -r constraints.in
9+
certifi==2021.10.8
10+
# via requests
11+
charset-normalizer==2.0.7
12+
# via requests
13+
idna==3.3
14+
# via requests
15+
lockfile==0.12.2
16+
# via cachecontrol
17+
msgpack==1.0.2
18+
# via cachecontrol
19+
requests==2.26.0
20+
# via cachecontrol
21+
urllib3==1.26.7
22+
# via requests

0 commit comments

Comments
 (0)