Source code for twine.exceptions

"""Module containing exceptions raised by twine."""
# Copyright 2015 Ian Stapleton Cordasco
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.

[docs]class TwineException(Exception): """Base class for all exceptions raised by twine.""" pass
[docs]class RedirectDetected(TwineException): """A redirect was detected that the user needs to resolve. In some cases, requests refuses to issue a new POST request after a redirect. In order to prevent a confusing user experience, we raise this exception to allow users to know the index they're uploading to is redirecting them. """
[docs] @classmethod def from_args(cls, repository_url: str, redirect_url: str) -> "RedirectDetected": if redirect_url == f"{repository_url}/": return cls( f"{repository_url} attempted to redirect to {redirect_url}.\n" f"Your repository URL is missing a trailing slash. " "Please add it and try again.", ) return cls( f"{repository_url} attempted to redirect to {redirect_url}.\n" f"If you trust these URLs, set {redirect_url} as your repository URL " "and try again.", )
[docs]class PackageNotFound(TwineException): """A package file was provided that could not be found on the file system. This is only used when attempting to register a package_file. """ pass
[docs]class UploadToDeprecatedPyPIDetected(TwineException): """An upload attempt was detected to deprecated PyPI domains. The sites and are deprecated. """
[docs] @classmethod def from_args( cls, target_url: str, default_url: str, test_url: str ) -> "UploadToDeprecatedPyPIDetected": """Return an UploadToDeprecatedPyPIDetected instance.""" return cls( "You're trying to upload to the legacy PyPI site '{}'. " "Uploading to those sites is deprecated. \n " "The new sites are and Try using " "{} (or {}) to upload your packages instead. " "These are the default URLs for Twine now. \n More at " "" " .".format(target_url, default_url, test_url) )
[docs]class UnreachableRepositoryURLDetected(TwineException): """An upload attempt was detected to a URL without a protocol prefix. All repository URLs must have a protocol (e.g., ``https://``). """ pass
[docs]class InvalidSigningConfiguration(TwineException): """Both the sign and identity parameters must be present.""" pass
[docs]class InvalidSigningExecutable(TwineException): """Signing executable must be installed on system.""" pass
[docs]class InvalidConfiguration(TwineException): """Raised when configuration is invalid.""" pass
[docs]class InvalidDistribution(TwineException): """Raised when a distribution is invalid.""" pass
[docs]class NonInteractive(TwineException): """Raised in non-interactive mode when credentials could not be found.""" pass
[docs]class InvalidPyPIUploadURL(TwineException): """Repository configuration tries to use PyPI with an incorrect URL. For example, instead of """ pass