Class: Dependabot::Python::FileUpdater

Inherits:
FileUpdaters::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/python/file_updater.rb,
lib/dependabot/python/file_updater/pipfile_preparer.rb,
lib/dependabot/python/file_updater/pyproject_preparer.rb,
lib/dependabot/python/file_updater/poetry_file_updater.rb,
lib/dependabot/python/file_updater/pipfile_file_updater.rb,
lib/dependabot/python/file_updater/requirement_replacer.rb,
lib/dependabot/python/file_updater/setup_file_sanitizer.rb,
lib/dependabot/python/file_updater/pip_compile_file_updater.rb,
lib/dependabot/python/file_updater/pipfile_manifest_updater.rb,
lib/dependabot/python/file_updater/requirement_file_updater.rb

Defined Under Namespace

Classes: PipCompileFileUpdater, PipfileFileUpdater, PipfileManifestUpdater, PipfilePreparer, PoetryFileUpdater, PyprojectPreparer, RequirementFileUpdater, RequirementReplacer, SetupFileSanitizer

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.updated_files_regexObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dependabot/python/file_updater.rb', line 21

def self.updated_files_regex
  [
    /^.*Pipfile$/,             # Match Pipfile at any level
    /^.*Pipfile\.lock$/,       # Match Pipfile.lock at any level
    /^.*\.txt$/,               # Match any .txt files (e.g., requirements.txt) at any level
    /^.*\.in$/,                # Match any .in files at any level
    /^.*setup\.py$/,           # Match setup.py at any level
    /^.*setup\.cfg$/,          # Match setup.cfg at any level
    /^.*pyproject\.toml$/,     # Match pyproject.toml at any level
    /^.*pyproject\.lock$/,     # Match pyproject.lock at any level
    /^.*poetry\.lock$/ # Match poetry.lock at any level
  ]
end

Instance Method Details

#updated_dependency_filesObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dependabot/python/file_updater.rb', line 36

def updated_dependency_files
  updated_files =
    case resolver_type
    when :pipfile then updated_pipfile_based_files
    when :poetry then updated_poetry_based_files
    when :pip_compile then updated_pip_compile_based_files
    when :requirements then updated_requirement_based_files
    else raise "Unexpected resolver type: #{resolver_type}"
    end

  if updated_files.none? ||
     updated_files.sort_by(&:name) == dependency_files.sort_by(&:name)
    raise "No files have changed!"
  end

  updated_files
end