diff --git a/twine/__main__.py b/twine/__main__.py index bfdc8028..4ccbdca8 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -27,10 +27,7 @@ def main(): try: return dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.exceptions.HTTPError) as exc: - return '{0}: {1}'.format( - exc.__class__.__name__, - exc.args[0], - ) + return '{}: {}'.format(exc.__class__.__name__, exc.args[0]) if __name__ == "__main__": diff --git a/twine/cli.py b/twine/cli.py index 9dbfe51c..aac9a8eb 100644 --- a/twine/cli.py +++ b/twine/cli.py @@ -29,7 +29,7 @@ def _registered_commands(group='twine.registered_commands'): registered_commands = pkg_resources.iter_entry_points(group=group) - return dict((c.name, c) for c in registered_commands) + return {c.name: c for c in registered_commands} def list_dependencies_and_versions(): @@ -44,7 +44,7 @@ def list_dependencies_and_versions(): def dep_versions(): return ', '.join( - '{0}: {1}'.format(*dependency) + '{}: {}'.format(*dependency) for dependency in list_dependencies_and_versions() ) @@ -55,8 +55,10 @@ def dispatch(argv): parser.add_argument( "--version", action="version", - version="%(prog)s version {0} ({1})".format(twine.__version__, - dep_versions()), + version="%(prog)s version {} ({})".format( + twine.__version__, + dep_versions(), + ), ) parser.add_argument( "command", diff --git a/twine/commands/register.py b/twine/commands/register.py index ed5021f9..3b97a695 100644 --- a/twine/commands/register.py +++ b/twine/commands/register.py @@ -24,12 +24,12 @@ def register(register_settings, package): repository_url = register_settings.repository_config['repository'] - print("Registering package to {0}".format(repository_url)) + print("Registering package to {}".format(repository_url)) repository = register_settings.create_repository() if not os.path.exists(package): raise exceptions.PackageNotFound( - '"{0}" does not exist on the file system.'.format(package) + '"{}" does not exist on the file system.'.format(package) ) resp = repository.register( diff --git a/twine/commands/upload.py b/twine/commands/upload.py index c98d7075..0b78fe89 100644 --- a/twine/commands/upload.py +++ b/twine/commands/upload.py @@ -28,7 +28,7 @@ def skip_upload(response, skip_existing, package): filename = package.basefilename msg_400 = ( # Old PyPI message: - 'A file named "{0}" already exists for'.format(filename), + 'A file named "{}" already exists for'.format(filename), # Warehouse message: 'File already exists', # Nexus Repository OSS message: @@ -55,21 +55,19 @@ def upload(upload_settings, dists): dists = _find_dists(dists) # Determine if the user has passed in pre-signed distributions - signatures = dict( - (os.path.basename(d), d) for d in dists if d.endswith(".asc") - ) + signatures = {os.path.basename(d): d for d in dists if d.endswith(".asc")} uploads = [i for i in dists if not i.endswith(".asc")] upload_settings.check_repository_url() repository_url = upload_settings.repository_config['repository'] - print("Uploading distributions to {0}".format(repository_url)) + print("Uploading distributions to {}".format(repository_url)) repository = upload_settings.create_repository() for filename in uploads: package = PackageFile.from_filename(filename, upload_settings.comment) skip_message = ( - " Skipping {0} because it appears to already exist".format( + " Skipping {} because it appears to already exist".format( package.basefilename) ) diff --git a/twine/exceptions.py b/twine/exceptions.py index c6a710ce..2fdc9885 100644 --- a/twine/exceptions.py +++ b/twine/exceptions.py @@ -50,10 +50,10 @@ class UploadToDeprecatedPyPIDetected(TwineException): @classmethod def from_args(cls, target_url, default_url, test_url): """Return an UploadToDeprecatedPyPIDetected instance.""" - return cls("You're trying to upload to the legacy PyPI site '{0}'. " + return cls("You're trying to upload to the legacy PyPI site '{}'. " "Uploading to those sites is deprecated. \n " "The new sites are pypi.org and test.pypi.org. Try using " - "{1} (or {2}) to upload your packages instead. " + "{} (or {}) to upload your packages instead. " "These are the default URLs for Twine now. \n More at " "https://packaging.python.org/guides/migrating-to-pypi-org/" " .".format(target_url, default_url, test_url) diff --git a/twine/package.py b/twine/package.py index d76a72de..c838c88e 100644 --- a/twine/package.py +++ b/twine/package.py @@ -160,7 +160,7 @@ def add_gpg_signature(self, signature_filepath, signature_filename): self.gpg_signature = (signature_filename, gpg.read()) def sign(self, sign_with, identity): - print("Signing {0}".format(self.basefilename)) + print("Signing {}".format(self.basefilename)) gpg_args = (sign_with, "--detach-sign") if identity: gpg_args += ("--local-user", identity) diff --git a/twine/repository.py b/twine/repository.py index 1038291c..b92ac9be 100644 --- a/twine/repository.py +++ b/twine/repository.py @@ -28,7 +28,7 @@ import twine -KEYWORDS_TO_NOT_FLATTEN = set(["gpg_signature", "content"]) +KEYWORDS_TO_NOT_FLATTEN = {"gpg_signature", "content"} LEGACY_PYPI = 'https://pypi.python.org/' LEGACY_TEST_PYPI = 'https://testpypi.python.org/' @@ -106,7 +106,7 @@ def register(self, package): "protocol_version": "1", }) - print("Registering {0}".format(package.basefilename)) + print("Registering {}".format(package.basefilename)) data_to_send = self._convert_data_to_list_of_tuples(data) encoder = MultipartEncoder(data_to_send) @@ -130,7 +130,7 @@ def _upload(self, package): data_to_send = self._convert_data_to_list_of_tuples(data) - print("Uploading {0}".format(package.basefilename)) + print("Uploading {}".format(package.basefilename)) with open(package.filename, "rb") as fp: data_to_send.append(( diff --git a/twine/utils.py b/twine/utils.py index fc3042f5..79ae4bf9 100644 --- a/twine/utils.py +++ b/twine/utils.py @@ -115,7 +115,7 @@ def get_repository_from_config(config_file, repository, repository_url=None): } if repository_url and "://" not in repository_url: raise exceptions.UnreachableRepositoryURLDetected( - "Repository URL {0} has no protocol. Please add " + "Repository URL {} has no protocol. Please add " "'https://'. \n".format(repository_url)) try: return get_config(config_file)[repository] @@ -133,8 +133,8 @@ def get_repository_from_config(config_file, repository, repository_url=None): raise exceptions.InvalidConfiguration(msg) -_HOSTNAMES = set(["pypi.python.org", "testpypi.python.org", "upload.pypi.org", - "test.pypi.org"]) +_HOSTNAMES = {"pypi.python.org", "testpypi.python.org", "upload.pypi.org", + "test.pypi.org"} def normalize_repository_url(url):