Class: Dependabot::Python::FileParser::SetupFileParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/python/file_parser/setup_file_parser.rb

Constant Summary collapse

INSTALL_REQUIRES_REGEX =
/install_requires\s*=\s*(\[.*?\])[,)\s]/m.freeze
SETUP_REQUIRES_REGEX =
/setup_requires\s*=\s*(\[.*?\])[,)\s]/m.freeze
TESTS_REQUIRE_REGEX =
/tests_require\s*=\s*(\[.*?\])[,)\s]/m.freeze
EXTRAS_REQUIRE_REGEX =
/extras_require\s*=\s*(\{.*?\})[,)\s]/m.freeze

Instance Method Summary collapse

Constructor Details

#initialize(dependency_files:) ⇒ SetupFileParser

Returns a new instance of SetupFileParser.



20
21
22
# File 'lib/dependabot/python/file_parser/setup_file_parser.rb', line 20

def initialize(dependency_files:)
  @dependency_files = dependency_files
end

Instance Method Details

#dependency_setObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/dependabot/python/file_parser/setup_file_parser.rb', line 24

def dependency_set
  dependencies = Dependabot::FileParsers::Base::DependencySet.new

  parsed_setup_file.each do |dep|
    # If a requirement has a `<` or `<=` marker then updating it is
    # probably blocked. Ignore it.
    next if dep["markers"].include?("<")

    # If the requirement is our inserted version, ignore it
    # (we wouldn't be able to update it)
    next if dep["version"] == "0.0.1+dependabot"

    dependencies <<
      Dependency.new(
        name: normalised_name(dep["name"]),
        version: dep["version"]&.include?("*") ? nil : dep["version"],
        requirements: [{
          requirement: dep["requirement"],
          file: Pathname.new(dep["file"]).cleanpath.to_path,
          source: nil,
          groups: [dep["requirement_type"]]
        }],
        package_manager: "pip"
      )
  end
  dependencies
end