Class: Dependabot::Python::PoetryErrorHandler
- Inherits:
-
UpdateChecker
- Object
- UpdateCheckers::Base
- UpdateChecker
- Dependabot::Python::PoetryErrorHandler
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/python/update_checker/poetry_version_resolver.rb
Constant Summary collapse
- INVALID_CONFIGURATION =
if a valid config value is not found in project.toml file
/The Poetry configuration is invalid:(?<config>.*)/- INVALID_VERSION =
if .toml has incorrect version specification i.e. <0.2.0app
/Could not parse version constraint: (?<ver>.*)/- INVALID_LINK =
dependency source link not accessible
/No valid distribution links found for package: "(?<dep>.*)" version: "(?<ver>.*)"/- PYTHON_RANGE_NOT_SATISFIED =
Python version range mentioned in .toml [tool.poetry.dependencies] python = “x.x” is not satisfied by dependency
/(?<dep>.*) requires Python (?<req_ver>.*), so it will not be satisfied for Python (?<men_ver>.*)/- PACKAGE_NOT_FOUND =
package version mentioned in .toml not found in package index
/Package (?<pkg>.*) ((?<req_ver>.*)) not found./- CLIENT_ERROR_CODES =
client access error codes while accessing package index
T.let({ error401: /401 Client Error/, error403: /403 Client Error/, error404: /404 Client Error/, http403: /HTTP error 403/, http404: /HTTP error 404/ }.freeze, T::Hash[T.nilable(String), Regexp])
- SERVER_ERROR_CODES =
server response error codes while accessing package index
T.let({ server502: /502 Server Error/, server503: /503 Server Error/, server504: /504 Server Error/ }.freeze, T::Hash[T.nilable(String), Regexp])
- POETRY_VIRTUAL_ENV_CONFIG =
invalid configuration in pyproject.toml
%r{pypoetry/virtualenvs(.|\n)*list index out of range}- ERR_LOCAL_PROJECT_PATH =
error related to local project as dependency in pyproject.toml
/Path (?<path>.*) for (?<dep>.*) does not exist/
Constants inherited from UpdateChecker
UpdateChecker::MAIN_PYPI_INDEXES, UpdateChecker::VERSION_REGEX
Instance Method Summary collapse
- #handle_poetry_error(error) ⇒ Object
-
#initialize(dependencies:, dependency_files:) ⇒ PoetryErrorHandler
constructor
A new instance of PoetryErrorHandler.
Methods inherited from UpdateChecker
#latest_resolvable_version, #latest_resolvable_version_with_no_unlock, #latest_version, #lowest_resolvable_security_fix_version, #lowest_security_fix_version, #requirements_unlocked_or_can_be?, #requirements_update_strategy, #updated_requirements
Constructor Details
#initialize(dependencies:, dependency_files:) ⇒ PoetryErrorHandler
Returns a new instance of PoetryErrorHandler.
384 385 386 387 |
# File 'lib/dependabot/python/update_checker/poetry_version_resolver.rb', line 384 def initialize(dependencies:, dependency_files:) @dependencies = dependencies @dependency_files = dependency_files end |
Instance Method Details
#handle_poetry_error(error) ⇒ Object
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/dependabot/python/update_checker/poetry_version_resolver.rb', line 411 def handle_poetry_error(error) Dependabot.logger.warn(error.) if (msg = error..match(PoetryVersionResolver::INCOMPATIBLE_CONSTRAINTS) || error..match(INVALID_CONFIGURATION) || error..match(INVALID_VERSION) || error..match(INVALID_LINK)) raise DependencyFileNotResolvable, msg end if (msg = error..match(PACKAGE_NOT_FOUND)) raise DependencyFileNotResolvable, msg end raise DependencyFileNotResolvable, error. if error..match(PYTHON_RANGE_NOT_SATISFIED) if error..match(POETRY_VIRTUAL_ENV_CONFIG) || error..match(ERR_LOCAL_PROJECT_PATH) msg = "Error while resolving pyproject.toml file" raise DependencyFileNotResolvable, msg end SERVER_ERROR_CODES.each do |(_error_codes, error_regex)| next unless error..match?(error_regex) index_url = URI.extract(error..to_s).last .then { sanitize_url(_1) } raise InconsistentRegistryResponse, index_url end CLIENT_ERROR_CODES.each do |(_error_codes, error_regex)| next unless error..match?(error_regex) index_url = URI.extract(error..to_s).last .then { sanitize_url(_1) } raise PrivateSourceAuthenticationFailure, index_url end end |