Class: Dependabot::Python::UpdateChecker::PipenvVersionResolver

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/python/update_checker/pipenv_version_resolver.rb

Constant Summary collapse

GIT_DEPENDENCY_UNREACHABLE_REGEX =
/git clone --filter=blob:none --quiet (?<url>[^\s]+).*/
GIT_REFERENCE_NOT_FOUND_REGEX =
/git checkout -q (?<tag>[^\s]+).*/
PIPENV_INSTALLATION_ERROR_NEW =
"Getting requirements to build wheel exited with 1"
PIPENV_INSTALLATION_ERROR_OLD =

Can be removed when Python 3.11 support is dropped

T.let(Regexp.quote("python setup.py egg_info exited with 1"), String)
PIPENV_INSTALLATION_ERROR =
/#{PIPENV_INSTALLATION_ERROR_NEW}|#{PIPENV_INSTALLATION_ERROR_OLD}/
PIPENV_INSTALLATION_ERROR_REGEX =
/[\s\S]*Collecting\s(?<name>.+)\s\(from\s-r.+\)[\s\S]*(#{PIPENV_INSTALLATION_ERROR})/
PIPENV_RANGE_WARNING =
/Python version range specifier '(?<ver>.*)' is not supported/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, dependency_files:, credentials:, repo_contents_path:) ⇒ PipenvVersionResolver

Returns a new instance of PipenvVersionResolver.



58
59
60
61
62
63
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 58

def initialize(dependency:, dependency_files:, credentials:, repo_contents_path:)
  @dependency = T.let(dependency, Dependabot::Dependency)
  @dependency_files = T.let(dependency_files, T::Array[Dependabot::DependencyFile])
  @credentials = T.let(credentials, T::Array[Dependabot::Credential])
  @repo_contents_path = T.let(repo_contents_path, T.nilable(String))
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



45
46
47
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 45

def credentials
  @credentials
end

#dependencyObject (readonly)

Returns the value of attribute dependency.



39
40
41
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 39

def dependency
  @dependency
end

#dependency_filesObject (readonly)

Returns the value of attribute dependency_files.



42
43
44
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 42

def dependency_files
  @dependency_files
end

#repo_contents_pathObject (readonly)

Returns the value of attribute repo_contents_path.



48
49
50
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 48

def repo_contents_path
  @repo_contents_path
end

Instance Method Details

#latest_resolvable_version(requirement: nil) ⇒ Object



66
67
68
69
70
71
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 66

def latest_resolvable_version(requirement: nil)
  version_string =
    fetch_latest_resolvable_version_string(requirement: requirement)

  version_string.nil? ? nil : Python::Version.new(version_string)
end

#resolvable?(version:) ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
77
78
79
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 74

def resolvable?(version:)
  @resolvable ||= T.let({}, T.nilable(T::Hash[Gem::Version, T::Boolean]))
  return T.must(@resolvable[version]) if @resolvable.key?(version)

  @resolvable[version] = !!fetch_latest_resolvable_version_string(requirement: "==#{version}")
end