Class: Dependabot::Python::FileParser

Inherits:
FileParsers::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/python/file_parser.rb,
lib/dependabot/python/file_parser/setup_file_parser.rb,
lib/dependabot/python/file_parser/pipfile_files_parser.rb,
lib/dependabot/python/file_parser/pyproject_files_parser.rb,
lib/dependabot/python/file_parser/python_requirement_parser.rb

Overview

rubocop:disable Metrics/ClassLength

Defined Under Namespace

Classes: PipfileFilesParser, PyprojectFilesParser, PythonRequirementParser, SetupFileParser

Constant Summary collapse

DEPENDENCY_GROUP_KEYS =
T.let(
  [
    {
      pipfile: "packages",
      lockfile: "default"
    },
    {
      pipfile: "dev-packages",
      lockfile: "develop"
    }
  ].freeze,
  T::Array[T::Hash[Symbol, String]]
)
REQUIREMENT_FILE_EVALUATION_ERRORS =
%w(
  InstallationError RequirementsFileParseError InvalidMarker
  InvalidRequirement ValueError RecursionError
).freeze
UNDETECTED_PACKAGE_MANAGER_VERSION =

we use this placeholder version in case we are not able to detect any PIP version from shell, we are ensuring that the actual update is not blocked in any way if any metric collection exception start happening

"0.0"

Instance Method Summary collapse

Instance Method Details

#ecosystemObject



67
68
69
70
71
72
73
74
75
76
# File 'lib/dependabot/python/file_parser.rb', line 67

def ecosystem
  @ecosystem ||= T.let(
    Ecosystem.new(
      name: ECOSYSTEM,
      package_manager: package_manager,
      language: language
    ),
    T.nilable(Ecosystem)
  )
end

#parseObject

Raises:

  • (Dependabot::UnexpectedExternalCode)


52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/dependabot/python/file_parser.rb', line 52

def parse
  # TODO: setup.py from external dependencies is evaluated. Provide guards before removing this.
  raise Dependabot::UnexpectedExternalCode if @reject_external_code

  dependency_set = DependencySet.new

  dependency_set += pipenv_dependencies if pipfile
  dependency_set += pyproject_file_dependencies if pyproject
  dependency_set += requirement_dependencies if requirement_files.any?
  dependency_set += setup_file_dependencies if setup_file || setup_cfg_file

  dependency_set.dependencies
end