dependabot-python 0.404.0 → 0.405.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 +4 -4
- data/helpers/lib/parser.py +14 -9
- data/helpers/run.py +1 -1
- data/helpers/test/test_parse_requirements.py +17 -0
- data/lib/dependabot/python/dependency_grapher/requirements_layers.rb +2 -24
- data/lib/dependabot/python/dependency_grapher.rb +7 -3
- data/lib/dependabot/python/file_parser/pep_dependency.rb +4 -1
- data/lib/dependabot/python/file_parser/poetry_lock/record.rb +124 -0
- data/lib/dependabot/python/file_parser/poetry_lock.rb +73 -39
- data/lib/dependabot/python/file_parser/pyproject_document/pep621_mutations.rb +154 -0
- data/lib/dependabot/python/file_parser/pyproject_document/poetry_mutations.rb +195 -0
- data/lib/dependabot/python/file_parser/pyproject_document.rb +3 -0
- data/lib/dependabot/python/file_parser.rb +58 -7
- data/lib/dependabot/python/file_updater/poetry_file_updater.rb +46 -86
- data/lib/dependabot/python/file_updater/pyproject_preparer.rb +32 -212
- data/lib/dependabot/python/file_updater.rb +7 -3
- data/lib/dependabot/python/marker_evaluator.rb +13 -2
- data/lib/dependabot/python/poetry_subdependency_pin.rb +20 -106
- data/lib/dependabot/python/requirement_references.rb +34 -0
- data/lib/dependabot/python/shared_file_fetcher.rb +3 -2
- data/lib/dependabot/python/update_checker/poetry_version_resolver.rb +29 -63
- metadata +8 -4
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
require "sorbet-runtime"
|
|
5
5
|
require "excon"
|
|
6
|
-
require "toml-rb"
|
|
7
6
|
require "open3"
|
|
8
7
|
require "uri"
|
|
9
8
|
require "dependabot/dependency"
|
|
10
9
|
require "dependabot/errors"
|
|
11
10
|
require "dependabot/shared_helpers"
|
|
12
11
|
require "dependabot/python/file_parser"
|
|
12
|
+
require "dependabot/python/file_parser/poetry_lock"
|
|
13
13
|
require "dependabot/python/file_parser/python_requirement_parser"
|
|
14
14
|
require "dependabot/python/file_updater/pyproject_preparer"
|
|
15
15
|
require "dependabot/python/update_checker"
|
|
@@ -142,9 +142,7 @@ module Dependabot
|
|
|
142
142
|
run_poetry_update_command
|
|
143
143
|
|
|
144
144
|
updated_lockfile = File.read("poetry.lock")
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
fetch_version_from_parsed_lockfile(updated_lockfile)
|
|
145
|
+
fetch_version_from_lockfile(updated_lockfile)
|
|
148
146
|
rescue PoetrySubdependencyPin::ScopeNotReproducible
|
|
149
147
|
nil
|
|
150
148
|
rescue SharedHelpers::HelperSubprocessFailed => e
|
|
@@ -153,12 +151,11 @@ module Dependabot
|
|
|
153
151
|
end
|
|
154
152
|
end
|
|
155
153
|
|
|
156
|
-
sig { params(
|
|
157
|
-
def
|
|
158
|
-
version =
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
&.fetch("version")
|
|
154
|
+
sig { params(content: String).returns(T.nilable(String)) }
|
|
155
|
+
def fetch_version_from_lockfile(content)
|
|
156
|
+
version = FileParser::PoetryLock.from_content(content)
|
|
157
|
+
.record_for(dependency.name) { |name| normalise(name) }
|
|
158
|
+
&.version
|
|
162
159
|
|
|
163
160
|
return version unless version.nil? && dependency.top_level?
|
|
164
161
|
|
|
@@ -250,6 +247,12 @@ module Dependabot
|
|
|
250
247
|
updated_req: nil,
|
|
251
248
|
update_pyproject: true
|
|
252
249
|
)
|
|
250
|
+
content = if update_pyproject
|
|
251
|
+
updated_pyproject_content(updated_requirement: updated_req)
|
|
252
|
+
else
|
|
253
|
+
sanitized_pyproject_content
|
|
254
|
+
end
|
|
255
|
+
|
|
253
256
|
dependency_files.each do |file|
|
|
254
257
|
path = file.name
|
|
255
258
|
FileUtils.mkdir_p(Pathname.new(path).dirname)
|
|
@@ -260,14 +263,7 @@ module Dependabot
|
|
|
260
263
|
File.write(".python-version", language_version_manager.python_major_minor)
|
|
261
264
|
|
|
262
265
|
# Overwrite the pyproject with updated content
|
|
263
|
-
|
|
264
|
-
File.write(
|
|
265
|
-
"pyproject.toml",
|
|
266
|
-
updated_pyproject_content(updated_requirement: updated_req)
|
|
267
|
-
)
|
|
268
|
-
else
|
|
269
|
-
File.write("pyproject.toml", sanitized_pyproject_content)
|
|
270
|
-
end
|
|
266
|
+
File.write("pyproject.toml", content)
|
|
271
267
|
end
|
|
272
268
|
|
|
273
269
|
sig { void }
|
|
@@ -326,16 +322,15 @@ module Dependabot
|
|
|
326
322
|
return pyproject_content
|
|
327
323
|
end
|
|
328
324
|
|
|
329
|
-
|
|
330
|
-
poetry_object = pyproject_object.dig("tool", "poetry")
|
|
325
|
+
document = FileParser::PyprojectDocument.from_content(pyproject_content)
|
|
331
326
|
|
|
332
|
-
if
|
|
333
|
-
set_poetry_target_dependency_req(
|
|
334
|
-
elsif
|
|
335
|
-
set_pep621_target_dependency_req(
|
|
327
|
+
if document.poetry?
|
|
328
|
+
set_poetry_target_dependency_req(document, updated_requirement)
|
|
329
|
+
elsif poetry_lock && document.poetry_build_backend?
|
|
330
|
+
set_pep621_target_dependency_req(document, updated_requirement)
|
|
336
331
|
end
|
|
337
332
|
|
|
338
|
-
|
|
333
|
+
document.to_toml
|
|
339
334
|
end
|
|
340
335
|
|
|
341
336
|
sig { params(pyproject_content: String).returns(T::Boolean) }
|
|
@@ -343,53 +338,24 @@ module Dependabot
|
|
|
343
338
|
!poetry_lock.nil? && FileParser::PyprojectDocument.from_content(pyproject_content).poetry_build_backend?
|
|
344
339
|
end
|
|
345
340
|
|
|
346
|
-
sig { params(
|
|
347
|
-
def set_poetry_target_dependency_req(
|
|
348
|
-
|
|
349
|
-
dependencies = poetry_object[type]
|
|
350
|
-
next unless dependencies
|
|
351
|
-
|
|
352
|
-
update_dependency_requirement(dependencies, updated_requirement)
|
|
353
|
-
end
|
|
354
|
-
|
|
355
|
-
groups = poetry_object["group"]&.values || []
|
|
356
|
-
groups.each do |group_spec|
|
|
357
|
-
update_dependency_requirement(group_spec["dependencies"], updated_requirement)
|
|
358
|
-
end
|
|
341
|
+
sig { params(document: FileParser::PyprojectDocument, updated_requirement: String).void }
|
|
342
|
+
def set_poetry_target_dependency_req(document, updated_requirement)
|
|
343
|
+
document.set_poetry_requirement(name: dependency.name, requirement: updated_requirement)
|
|
359
344
|
|
|
360
345
|
# If this is a sub-dependency, add the new requirement
|
|
361
346
|
return if dependency.requirements.find { |r| r.file == T.must(pyproject).name }
|
|
362
347
|
|
|
363
|
-
|
|
364
|
-
|
|
348
|
+
document.add_poetry_dependency(
|
|
349
|
+
name: dependency.name, requirement: updated_requirement, production: dependency.production?
|
|
350
|
+
)
|
|
365
351
|
end
|
|
366
352
|
|
|
367
353
|
# PEP 621 projects have no [tool.poetry] table to pin dependencies in. This file is only ever used
|
|
368
354
|
# as scratch input to run `poetry lock`, so it never reaches the real manifest.
|
|
369
|
-
sig { params(
|
|
370
|
-
def set_pep621_target_dependency_req(
|
|
355
|
+
sig { params(document: FileParser::PyprojectDocument, updated_requirement: String).void }
|
|
356
|
+
def set_pep621_target_dependency_req(document, updated_requirement)
|
|
371
357
|
PoetrySubdependencyPin.new(poetry_lock, dependency.name)
|
|
372
|
-
.set_requirement!(
|
|
373
|
-
end
|
|
374
|
-
|
|
375
|
-
sig { params(toml_node: T.nilable(T::Hash[String, T.untyped]), requirement: String).void }
|
|
376
|
-
def update_dependency_requirement(toml_node, requirement)
|
|
377
|
-
return unless toml_node
|
|
378
|
-
|
|
379
|
-
names = toml_node.keys
|
|
380
|
-
pkg_name = names.find { |nm| normalise(nm) == dependency.name }
|
|
381
|
-
return unless pkg_name
|
|
382
|
-
|
|
383
|
-
if toml_node[pkg_name].is_a?(Hash)
|
|
384
|
-
toml_node[pkg_name]["version"] = requirement
|
|
385
|
-
else
|
|
386
|
-
toml_node[pkg_name] = requirement
|
|
387
|
-
end
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
sig { returns(String) }
|
|
391
|
-
def subdep_type
|
|
392
|
-
dependency.production? ? "dependencies" : "dev-dependencies"
|
|
358
|
+
.set_requirement!(document, updated_requirement)
|
|
393
359
|
end
|
|
394
360
|
|
|
395
361
|
sig { returns(FileParser::PythonRequirementParser) }
|
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.
|
|
4
|
+
version: 0.405.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.
|
|
18
|
+
version: 0.405.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.
|
|
25
|
+
version: 0.405.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: debug
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -285,7 +285,10 @@ files:
|
|
|
285
285
|
- lib/dependabot/python/file_parser/pipfile_files_parser.rb
|
|
286
286
|
- lib/dependabot/python/file_parser/pipfile_lock_document.rb
|
|
287
287
|
- lib/dependabot/python/file_parser/poetry_lock.rb
|
|
288
|
+
- lib/dependabot/python/file_parser/poetry_lock/record.rb
|
|
288
289
|
- lib/dependabot/python/file_parser/pyproject_document.rb
|
|
290
|
+
- lib/dependabot/python/file_parser/pyproject_document/pep621_mutations.rb
|
|
291
|
+
- lib/dependabot/python/file_parser/pyproject_document/poetry_mutations.rb
|
|
289
292
|
- lib/dependabot/python/file_parser/pyproject_files_parser.rb
|
|
290
293
|
- lib/dependabot/python/file_parser/python_requirement_parser.rb
|
|
291
294
|
- lib/dependabot/python/file_parser/setup_file_parser.rb
|
|
@@ -318,6 +321,7 @@ files:
|
|
|
318
321
|
- lib/dependabot/python/poetry_subdependency_pin.rb
|
|
319
322
|
- lib/dependabot/python/requirement.rb
|
|
320
323
|
- lib/dependabot/python/requirement_parser.rb
|
|
324
|
+
- lib/dependabot/python/requirement_references.rb
|
|
321
325
|
- lib/dependabot/python/shared_file_fetcher.rb
|
|
322
326
|
- lib/dependabot/python/update_checker.rb
|
|
323
327
|
- lib/dependabot/python/update_checker/latest_version_finder.rb
|
|
@@ -332,7 +336,7 @@ licenses:
|
|
|
332
336
|
- MIT
|
|
333
337
|
metadata:
|
|
334
338
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
|
335
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
|
339
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.405.0
|
|
336
340
|
rdoc_options: []
|
|
337
341
|
require_paths:
|
|
338
342
|
- lib
|