summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-05-26 19:11:41 (GMT)
committerGitHub <noreply@github.com>2021-05-26 19:11:41 (GMT)
commit78a8428548445b501f5ebd6ff4647d93ffd8efd1 (patch)
treefe85a1f99132fefb3f4e3735b9ab022477995bf4 /Lib/importlib
parent1261941e02cd04829592b1b1360b4ec21bfcdb9a (diff)
downloadcpython-78a8428548445b501f5ebd6ff4647d93ffd8efd1.zip
cpython-78a8428548445b501f5ebd6ff4647d93ffd8efd1.tar.gz
cpython-78a8428548445b501f5ebd6ff4647d93ffd8efd1.tar.bz2
bpo-38693: importlib.metadata f-strings (GH-26383)
Automerge-Triggered-By: GH:jaraco (cherry picked from commit e6c815d2e34be5fdf6dbe773f0781691746d2289) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/metadata/__init__.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/importlib/metadata/__init__.py b/Lib/importlib/metadata/__init__.py
index e2f2e47..629f185 100644
--- a/Lib/importlib/metadata/__init__.py
+++ b/Lib/importlib/metadata/__init__.py
@@ -47,8 +47,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):
@@ -385,7 +384,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:
@@ -569,13 +568,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 ''