bpo-38693: importlib.metadata f-strings (GH-26383)

Automerge-Triggered-By: GH:jaraco
This commit is contained in:
Jason R. Coombs 2021-05-26 14:49:06 -04:00 committed by GitHub
parent 06ac3a4742
commit e6c815d2e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -48,8 +48,7 @@ class PackageNotFoundError(ModuleNotFoundError):
"""The package was not found."""
def __str__(self):
tmpl = "No package metadata was found for {self.name}"
return tmpl.format(**locals())
return f"No package metadata was found for {self.name}"
@property
def name(self):
@ -386,7 +385,7 @@ class FileHash:
self.mode, _, self.value = spec.partition('=')
def __repr__(self):
return '<FileHash mode: {} value: {}>'.format(self.mode, self.value)
return f'<FileHash mode: {self.mode} value: {self.value}>'
class Distribution:
@ -570,13 +569,13 @@ class Distribution:
"""
def make_condition(name):
return name and 'extra == "{name}"'.format(name=name)
return name and f'extra == "{name}"'
def parse_condition(section):
section = section or ''
extra, sep, markers = section.partition(':')
if extra and markers:
markers = '({markers})'.format(markers=markers)
markers = f'({markers})'
conditions = list(filter(None, [markers, make_condition(extra)]))
return '; ' + ' and '.join(conditions) if conditions else ''

View File

@ -0,0 +1 @@
Importlib.metadata now prefers f-strings to .format.