dependabot-python 0.375.0 → 0.376.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78d82643ecf214fa9c9546719f86f904775a2df1adc1838daddef1306054a00a
4
- data.tar.gz: 68aca7a7062f67514acdf3616ee543eb830727dffb3ea2001bbec07612d3d6ab
3
+ metadata.gz: 8ea3de397765b873cd8faf8d93bde90b92e2254eace30c9603d46bf667af2bfb
4
+ data.tar.gz: d294b949dda1e010b01caae6c285f979c7c9510f55e57a8f7ed48b06c141d9ba
5
5
  SHA512:
6
- metadata.gz: '0548b008756712973354e457a020174748b741fa8d446975cfb543a8cb9663169e4a14ef7eb7390f275e97baa227ab1cc28f2d001add97ba7528bb415ca65249'
7
- data.tar.gz: 2432fe5ce55b1749d2ad09b99875157a66f3a3d1797d2217772d545dd727192d5562b5deae11e70c3e6331753b60000dbb2aa46d2aad4ce6dfc0996e1f569c41
6
+ metadata.gz: f9e0c083e6128c766189bdb911495eb37944f87dd8405ee6fdad569c59d65c19b7cfa18799a4fd4d8d869e55dea5c3e072b624d5e7f0639e96559b16782c65d5
7
+ data.tar.gz: f923f746f74bdc91ba8a47f3a1366250a90ebc178b0ae1eb94a012cb43777fedc854b19cb427ffcad4232408cf1bfc2f60bf04aaef8e58aee28cc3d9d039e5fe
@@ -18,6 +18,30 @@ module Dependabot
18
18
  class DependencyGrapher < Dependabot::DependencyGraphers::Base
19
19
  require_relative "dependency_grapher/lockfile_generator"
20
20
 
21
+ # Regex patterns for detecting Python requirements / dependencies .txt manifest variants.
22
+ # Used by the dependency grapher to filter out unrelated .txt files (e.g. README-style notes,
23
+ # tool output, etc.) from being treated as pip manifests.
24
+
25
+ # Matches "requirements" preceded by a hyphen, period, underscore, start-of-string, or slash,
26
+ # followed by non-whitespace chars and ".txt".
27
+ # Examples: requirements.txt, requirements.prod.txt, requirements/production.txt
28
+ REQUIREMENTS_TXT_REGEX = T.let(%r{(?:[-._]|^|/)requirements[^\s]*\.txt$}i, Regexp)
29
+
30
+ # More lenient: matches "require" with optional prefix (no dots/whitespace)
31
+ # and optional hyphen/underscore/slash suffix. Does not match "require" as a substring.
32
+ # Examples: require.txt, require-test.txt, py3-require.txt, pyenv_require_e2e.txt
33
+ REQUIRE_TXT_REGEX = T.let(%r{[^\s|.]*require(?:[-_/][^\s|.]*)?\.txt$}i, Regexp)
34
+
35
+ # Matches "dependencies" / "dependency" preceded by a hyphen, period, underscore,
36
+ # start-of-string, or slash, followed by non-whitespace chars and ".txt".
37
+ # Examples: dependencies.txt, my-dependencies.txt, dependencies/python/ansible-lint.txt
38
+ DEPENDENCIES_TXT_REGEX = T.let(%r{(?:[-._]|^|/)dependenc(?:y|ies)[^\s]*\.txt$}i, Regexp)
39
+
40
+ # More lenient: matches "depend" / "depends" with optional prefix (no dots/whitespace)
41
+ # and optional hyphen/underscore/slash suffix. Does not match "depend" as a substring.
42
+ # Examples: depend.txt, depends.txt, depend-test.txt, py3-depends.txt
43
+ DEPEND_TXT_REGEX = T.let(%r{[^\s|.]*depend(?:s)?(?:[-_/][^\s|.]*)?\.txt$}i, Regexp)
44
+
21
45
  sig { override.returns(Dependabot::DependencyFile) }
22
46
  def relevant_dependency_file
23
47
  dependency_files_by_package_manager = T.let(
@@ -352,11 +376,19 @@ module Dependabot
352
376
 
353
377
  @pip_requirements_file = T.let(
354
378
  dependency_files.find { |f| f.name == "requirements.txt" } ||
355
- dependency_files.find { |f| f.name.end_with?(".txt") },
379
+ dependency_files.find { |f| f.name.end_with?(".txt") && python_manifest_txt_filename?(f.name) },
356
380
  T.nilable(Dependabot::DependencyFile)
357
381
  )
358
382
  end
359
383
 
384
+ sig { params(path: String).returns(T::Boolean) }
385
+ def python_manifest_txt_filename?(path)
386
+ path.match?(REQUIREMENTS_TXT_REGEX) ||
387
+ path.match?(REQUIRE_TXT_REGEX) ||
388
+ path.match?(DEPENDENCIES_TXT_REGEX) ||
389
+ path.match?(DEPEND_TXT_REGEX)
390
+ end
391
+
360
392
  sig { params(filename: String).returns(T.nilable(Dependabot::DependencyFile)) }
361
393
  def dependency_file(filename)
362
394
  dependency_files.find { |file| file.name == filename }
@@ -26,19 +26,6 @@ module Dependabot
26
26
  DEPENDENCY_TYPES = T.let(%w(packages dev-packages).freeze, T::Array[String])
27
27
  MAX_FILE_SIZE = T.let(500_000, Integer)
28
28
 
29
- # Regex patterns for detecting Python requirements.txt manifest variants.
30
- # Ported from github/dependency-snapshots-api.
31
- #
32
- # Matches "requirements" preceded by a hyphen, period, underscore, start-of-string, or slash,
33
- # followed by non-whitespace chars and ".txt".
34
- # Examples: requirements.txt, requirements.prod.txt, requirements/production.txt
35
- REQUIREMENTS_TXT_REGEX = T.let(%r{(?:[-._]|^|/)requirements[^\s]*\.txt$}i, Regexp)
36
-
37
- # More lenient: matches "require" with optional prefix (no dots/whitespace)
38
- # and optional hyphen/underscore/slash suffix. Does not match "require" as a substring.
39
- # Examples: require.txt, require-test.txt, py3-require.txt, pyenv_require_e2e.txt
40
- REQUIRE_TXT_REGEX = T.let(%r{[^\s|.]*require(?:[-_/][^\s|.]*)?\.txt$}i, Regexp)
41
-
42
29
  sig { abstract.returns(T::Array[String]) }
43
30
  def self.ecosystem_specific_required_files; end
44
31
 
@@ -182,7 +169,7 @@ module Dependabot
182
169
 
183
170
  repo_contents
184
171
  .select { |f| f.type == "file" }
185
- .select { |f| potential_requirements_file?(f.name) }
172
+ .select { |f| f.name.end_with?(".txt", ".in") }
186
173
  .reject { |f| f.size > MAX_FILE_SIZE }
187
174
  .map { |f| fetch_file_from_host(f.name) }
188
175
  .select { |f| requirements_file?(f) }
@@ -206,7 +193,7 @@ module Dependabot
206
193
 
207
194
  repo_contents(dir: relative_reqs_dir)
208
195
  .select { |f| f.type == "file" }
209
- .select { |f| potential_requirements_file?(File.join(relative_reqs_dir, f.name)) }
196
+ .select { |f| File.join(relative_reqs_dir, f.name).end_with?(".txt", ".in") }
210
197
  .reject { |f| f.size > MAX_FILE_SIZE }
211
198
  .map { |f| fetch_file_from_host("#{relative_reqs_dir}/#{f.name}") }
212
199
  .select { |f| requirements_file?(f) }
@@ -392,24 +379,6 @@ module Dependabot
392
379
  uneditable_reqs + editable_reqs
393
380
  end
394
381
 
395
- # Checks if a filename matches known Python requirements.txt naming patterns.
396
- sig { params(path: String).returns(T::Boolean) }
397
- def requirements_txt_filename?(path)
398
- path.match?(REQUIREMENTS_TXT_REGEX) || path.match?(REQUIRE_TXT_REGEX)
399
- end
400
-
401
- # When the feature flag is enabled, only considers .txt files whose names match
402
- # requirements patterns (plus all .in files). When disabled, falls back to the
403
- # original behavior of accepting any .txt or .in file.
404
- sig { params(path: String).returns(T::Boolean) }
405
- def potential_requirements_file?(path)
406
- unless Dependabot::Experiments.enabled?(:python_requirements_file_name_filtering)
407
- return path.end_with?(".txt", ".in")
408
- end
409
-
410
- path.end_with?(".in") || requirements_txt_filename?(path)
411
- end
412
-
413
382
  sig { params(path: String).returns(String) }
414
383
  def clean_path(path)
415
384
  Pathname.new(path).cleanpath.to_path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-python
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.375.0
4
+ version: 0.376.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.375.0
18
+ version: 0.376.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.375.0
25
+ version: 0.376.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -322,7 +322,7 @@ licenses:
322
322
  - MIT
323
323
  metadata:
324
324
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
325
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.375.0
325
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.376.0
326
326
  rdoc_options: []
327
327
  require_paths:
328
328
  - lib