dependabot-python 0.110.14 → 0.110.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce7ac9110e4d9fad6510995f9938ccfac0ac5ce62bb7b56b6bd5be4ba3b5dc2a
4
- data.tar.gz: f0205fc6e19195f880333699486db230111912b3c79dfbde3fd02eb82b91df61
3
+ metadata.gz: 969f78c93199f4f7e88eae9764b88b6a3a76a0860c001c4fdb015205b39cf389
4
+ data.tar.gz: 9ba61eb87fd7b02cc18e448805b669cac0918f9e7e7485f3db214d4065aebb1f
5
5
  SHA512:
6
- metadata.gz: a51dbc2c9bf9baec3d0e7b0081a90d3022e5f5a55a80e4489407a73fdaab0518e4ab15fc5bda18a95bc1b73e68c6d255b8214ccff06481506a312b56a2874f1e
7
- data.tar.gz: a37f6ba59bd5009201c3b4242c7a1f6244bcc35429c9764a291b6f392538c1d508e62bbb89ccc1ba74fe47c1ffa5eaa835c1325d086255fdf505a1ccd484babd
6
+ metadata.gz: 0c62bbd0a1226594028680de60f154da19915133c2d2c97f090df9422d6dde4db493bcafbf5c1c69a036c018d86760c9fa79d1c9f05e946083e687f6d8b706b9
7
+ data.tar.gz: b39902d947dea6a3bd912cda1faf76dee526cb68c8bf1d62d7a6a0989b892c4c01949015737a5653495f2bf918b29f9e188ec9eeeffc20a2dae883e684719ddb
@@ -17,12 +17,12 @@ module Dependabot
17
17
  @dependency_files = dependency_files
18
18
  end
19
19
 
20
- # TODO: Parse setup.py and setup.cfg to get python requirement
21
20
  def user_specified_requirement
22
21
  pipfile_python_requirement ||
23
22
  pyproject_python_requirement ||
24
23
  python_version_file_version ||
25
- runtime_file_python_version
24
+ runtime_file_python_version ||
25
+ setup_file_requirement
26
26
  end
27
27
 
28
28
  # TODO: Add better Python version detection using dependency versions
@@ -88,18 +88,12 @@ module Dependabot
88
88
  file_version
89
89
  end
90
90
 
91
- def pipenv_python_requirement
92
- pipfile_lock_python_version || pipfile_python_requirement
93
- end
94
-
95
- def pipfile_lock_python_version
96
- return unless pipfile_lock
91
+ def setup_file_requirement
92
+ return unless setup_file
97
93
 
98
- JSON.parse(pipfile_lock.content).dig(
99
- "_meta",
100
- "host-environment-markers",
101
- "python_full_version"
102
- )
94
+ setup_file.content.
95
+ match(/python_requires\s*=\s*['"](?<req>[^'"]+)['"]/)&.
96
+ named_captures&.fetch("req")&.strip
103
97
  end
104
98
 
105
99
  def pyenv_versions
@@ -140,12 +134,8 @@ module Dependabot
140
134
  dependency_files.find { |f| f.name == "pyproject.toml" }
141
135
  end
142
136
 
143
- def setup_files
144
- dependency_files.select { |f| f.name.end_with?("setup.py") }
145
- end
146
-
147
- def setup_cfg_files
148
- dependency_files.select { |f| f.name.end_with?("setup.cfg") }
137
+ def setup_file
138
+ dependency_files.find { |f| f.name == "setup.py" }
149
139
  end
150
140
 
151
141
  def python_version_file
@@ -16,6 +16,7 @@ module Dependabot
16
16
  require_relative "update_checker/poetry_version_resolver"
17
17
  require_relative "update_checker/pipenv_version_resolver"
18
18
  require_relative "update_checker/pip_compile_version_resolver"
19
+ require_relative "update_checker/pip_version_resolver"
19
20
  require_relative "update_checker/requirements_updater"
20
21
  require_relative "update_checker/latest_version_finder"
21
22
 
@@ -45,10 +46,7 @@ module Dependabot
45
46
  requirement: unlocked_requirement_string
46
47
  )
47
48
  when :requirements
48
- # pip doesn't (yet) do any dependency resolution, so if we don't
49
- # have a Pipfile or a pip-compile file, we just return the latest
50
- # version.
51
- latest_version
49
+ pip_version_resolver.latest_resolvable_version
52
50
  else raise "Unexpected resolver type #{resolver_type}"
53
51
  end
54
52
  end
@@ -69,7 +67,7 @@ module Dependabot
69
67
  requirement: current_requirement_string
70
68
  )
71
69
  when :requirements
72
- latest_pip_version_with_no_unlock
70
+ pip_version_resolver.latest_resolvable_version_with_no_unlock
73
71
  else raise "Unexpected resolver type #{resolver_type}"
74
72
  end
75
73
  end
@@ -121,7 +119,10 @@ module Dependabot
121
119
  def fetch_lowest_resolvable_security_fix_version
122
120
  fix_version = latest_version_finder.lowest_security_fix_version
123
121
  return latest_resolvable_version if fix_version.nil?
124
- return fix_version if resolver_type == :requirements
122
+
123
+ if resolver_type == :requirements
124
+ return pip_version_resolver.lowest_resolvable_security_fix_version
125
+ end
125
126
 
126
127
  resolver =
127
128
  case resolver_type
@@ -186,6 +187,16 @@ module Dependabot
186
187
  @poetry_version_resolver ||= PoetryVersionResolver.new(resolver_args)
187
188
  end
188
189
 
190
+ def pip_version_resolver
191
+ @pip_version_resolver ||= PipVersionResolver.new(
192
+ dependency: dependency,
193
+ dependency_files: dependency_files,
194
+ credentials: credentials,
195
+ ignored_versions: ignored_versions,
196
+ security_advisories: security_advisories
197
+ )
198
+ end
199
+
189
200
  def resolver_args
190
201
  {
191
202
  dependency: dependency,
@@ -243,10 +254,6 @@ module Dependabot
243
254
  latest_version_finder.latest_version
244
255
  end
245
256
 
246
- def latest_pip_version_with_no_unlock
247
- latest_version_finder.latest_version_with_no_unlock
248
- end
249
-
250
257
  def latest_version_finder
251
258
  @latest_version_finder ||= LatestVersionFinder.new(
252
259
  dependency: dependency,
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dependabot/python/update_checker"
4
+ require "dependabot/python/update_checker/latest_version_finder"
5
+ require "dependabot/python/file_parser/python_requirement_parser"
6
+
7
+ module Dependabot
8
+ module Python
9
+ class UpdateChecker
10
+ class PipVersionResolver
11
+ def initialize(dependency:, dependency_files:, credentials:,
12
+ ignored_versions:, security_advisories:)
13
+ @dependency = dependency
14
+ @dependency_files = dependency_files
15
+ @credentials = credentials
16
+ @ignored_versions = ignored_versions
17
+ @security_advisories = security_advisories
18
+ end
19
+
20
+ def latest_resolvable_version
21
+ latest_version_finder.latest_version(python_version: python_version)
22
+ end
23
+
24
+ def latest_resolvable_version_with_no_unlock
25
+ latest_version_finder.
26
+ latest_version_with_no_unlock(python_version: python_version)
27
+ end
28
+
29
+ def lowest_resolvable_security_fix_version
30
+ latest_version_finder.
31
+ lowest_security_fix_version(python_version: python_version)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :dependency, :dependency_files, :credentials,
37
+ :ignored_versions, :security_advisories
38
+
39
+ def latest_version_finder
40
+ @latest_version_finder ||= LatestVersionFinder.new(
41
+ dependency: dependency,
42
+ dependency_files: dependency_files,
43
+ credentials: credentials,
44
+ ignored_versions: ignored_versions,
45
+ security_advisories: security_advisories
46
+ )
47
+ end
48
+
49
+ def python_version
50
+ @python_version ||=
51
+ user_specified_python_version ||
52
+ python_version_matching_imputed_requirements ||
53
+ PythonVersions::PRE_INSTALLED_PYTHON_VERSIONS.first
54
+ end
55
+
56
+ def user_specified_python_version
57
+ return unless python_requirement_parser.user_specified_requirement
58
+
59
+ user_specified_requirement =
60
+ Dependabot::Python::Requirement.new(
61
+ python_requirement_parser.user_specified_requirement
62
+ )
63
+ python_version_matching([user_specified_requirement])
64
+ end
65
+
66
+ def python_version_matching_imputed_requirements
67
+ compiled_file_python_requirement_markers =
68
+ python_requirement_parser.imputed_requirements.map do |r|
69
+ Dependabot::Python::Requirement.new(r)
70
+ end
71
+ python_version_matching(compiled_file_python_requirement_markers)
72
+ end
73
+
74
+ def python_version_matching(requirements)
75
+ PythonVersions::SUPPORTED_VERSIONS_TO_ITERATE.find do |version_string|
76
+ version = Python::Version.new(version_string)
77
+ requirements.all? { |req| req.satisfied_by?(version) }
78
+ end
79
+ end
80
+
81
+ def python_requirement_parser
82
+ @python_requirement_parser ||=
83
+ FileParser::PythonRequirementParser.
84
+ new(dependency_files: dependency_files)
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-python
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.110.14
4
+ version: 0.110.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-02 00:00:00.000000000 Z
11
+ date: 2019-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.110.14
19
+ version: 0.110.15
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.110.14
26
+ version: 0.110.15
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -176,6 +176,7 @@ files:
176
176
  - lib/dependabot/python/update_checker/index_finder.rb
177
177
  - lib/dependabot/python/update_checker/latest_version_finder.rb
178
178
  - lib/dependabot/python/update_checker/pip_compile_version_resolver.rb
179
+ - lib/dependabot/python/update_checker/pip_version_resolver.rb
179
180
  - lib/dependabot/python/update_checker/pipenv_version_resolver.rb
180
181
  - lib/dependabot/python/update_checker/poetry_version_resolver.rb
181
182
  - lib/dependabot/python/update_checker/requirements_updater.rb