Class: Dependabot::Python::UpdateChecker::PipCompileVersionResolver
- Inherits:
-
Object
- Object
- Dependabot::Python::UpdateChecker::PipCompileVersionResolver
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/python/update_checker/pip_compile_version_resolver.rb
Overview
This class does version resolution for pip-compile. Its approach is:
- Unlock the dependency we're checking in the requirements.in file
- Run
pip-compileand see what the result is
Constant Summary collapse
- GIT_DEPENDENCY_UNREACHABLE_REGEX =
/git clone --filter=blob:none --quiet (?<url>[^\s]+).* /- GIT_REFERENCE_NOT_FOUND_REGEX =
/Did not find branch or tag '(?<tag>[^\n"]+)'/m- NATIVE_COMPILATION_ERROR =
"pip._internal.exceptions.InstallationSubprocessError: Getting requirements to build wheel exited with 1"- PYTHON_PACKAGE_NAME_REGEX =
/[A-Za-z0-9_\-]+/- RESOLUTION_IMPOSSIBLE_ERROR =
"ResolutionImpossible"- ERROR_REGEX =
/(?<=ERROR\:\W).*$/
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#dependency_files ⇒ Object
readonly
Returns the value of attribute dependency_files.
-
#error_handler ⇒ Object
readonly
Returns the value of attribute error_handler.
-
#repo_contents_path ⇒ Object
readonly
Returns the value of attribute repo_contents_path.
Instance Method Summary collapse
-
#initialize(dependency:, dependency_files:, credentials:, repo_contents_path:) ⇒ PipCompileVersionResolver
constructor
A new instance of PipCompileVersionResolver.
- #latest_resolvable_version(requirement: nil) ⇒ Object
- #resolvable?(version:) ⇒ Boolean
Constructor Details
#initialize(dependency:, dependency_files:, credentials:, repo_contents_path:) ⇒ PipCompileVersionResolver
Returns a new instance of PipCompileVersionResolver.
62 63 64 65 66 67 68 69 |
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 62 def initialize(dependency:, dependency_files:, credentials:, repo_contents_path:) @dependency = dependency @dependency_files = dependency_files @credentials = credentials @repo_contents_path = repo_contents_path @build_isolation = T.let(true, T::Boolean) @error_handler = T.let(PipCompileErrorHandler.new, PipCompileErrorHandler) end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
46 47 48 |
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 46 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
40 41 42 |
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 40 def dependency @dependency end |
#dependency_files ⇒ Object (readonly)
Returns the value of attribute dependency_files.
43 44 45 |
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 43 def dependency_files @dependency_files end |
#error_handler ⇒ Object (readonly)
Returns the value of attribute error_handler.
52 53 54 |
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 52 def error_handler @error_handler end |
#repo_contents_path ⇒ Object (readonly)
Returns the value of attribute repo_contents_path.
49 50 51 |
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 49 def repo_contents_path @repo_contents_path end |
Instance Method Details
#latest_resolvable_version(requirement: nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 72 def latest_resolvable_version(requirement: nil) @latest_resolvable_version_string ||= T.let( {}, T.nilable(T::Hash[T.nilable(String), T.nilable(Dependabot::Python::Version)]) ) return @latest_resolvable_version_string[requirement] if @latest_resolvable_version_string.key?(requirement) version_string = fetch_latest_resolvable_version_string(requirement: requirement) @latest_resolvable_version_string[requirement] ||= version_string.nil? ? nil : Python::Version.new(version_string) end |
#resolvable?(version:) ⇒ Boolean
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 87 def resolvable?(version:) return false if version.nil? @resolvable ||= T.let({}, T.nilable(T::Hash[Gem::Version, T::Boolean])) return T.must(@resolvable[version]) if @resolvable.key?(version) @resolvable[version] = if latest_resolvable_version(requirement: "==#{version}") true else false end end |