summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-05-01 18:26:17 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-05-02 07:38:19 -0400
commit14449eedfa140b5a55896b9e064d3b52af9670f5 (patch)
treec5b8ac9517066de8cacfe577c945f2ccfa26ab20
parentddf5ba8cfcfe7d133ddbf888cc6e3af79863c712 (diff)
downloadpython-coveragepy-git-14449eedfa140b5a55896b9e064d3b52af9670f5.tar.gz
refactor: pyupgrade --py36-plus *.py
-rw-r--r--igor.py31
-rw-r--r--setup.py6
2 files changed, 18 insertions, 19 deletions
diff --git a/igor.py b/igor.py
index 8d162798..c31d21b3 100644
--- a/igor.py
+++ b/igor.py
@@ -1,4 +1,3 @@
-# coding: utf-8
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
@@ -49,7 +48,7 @@ def do_show_env():
"""Show the environment variables."""
print("Environment:")
for env in sorted(os.environ):
- print(" %s = %r" % (env, os.environ[env]))
+ print(f" {env} = {os.environ[env]!r}")
def do_remove_extension():
@@ -93,7 +92,7 @@ def should_skip(tracer):
skipper = "Only one tracer: no Python tracer for CPython"
else:
if tracer == "c":
- skipper = "No C tracer for {}".format(platform.python_implementation())
+ skipper = f"No C tracer for {platform.python_implementation()}"
elif tracer == "py":
# $set_env.py: COVERAGE_NO_PYTRACER - Don't run the tests under the Python tracer.
skipper = os.environ.get("COVERAGE_NO_PYTRACER")
@@ -117,7 +116,7 @@ def make_env_id(tracer):
version = "%s%s" % sys.version_info[:2]
if PYPY:
version += "_%s%s" % sys.pypy_version_info[:2]
- env_id = "%s%s_%s" % (impl, version, tracer)
+ env_id = f"{impl}{version}_{tracer}"
return env_id
@@ -149,7 +148,7 @@ def run_tests_with_coverage(tracer, *runner_args):
with open(pth_path, "w") as pth_file:
pth_file.write("import coverage; coverage.process_startup()\n")
- suffix = "%s_%s" % (make_env_id(tracer), platform.platform())
+ suffix = f"{make_env_id(tracer)}_{platform.platform()}"
os.environ['COVERAGE_METAFILE'] = os.path.abspath(".metacov."+suffix)
import coverage
@@ -224,7 +223,7 @@ def do_zip_mods():
zf.write("tests/covmodzip1.py", "covmodzip1.py")
# The others will be various encodings.
- source = textwrap.dedent(u"""\
+ source = textwrap.dedent("""\
# coding: {encoding}
text = u"{text}"
ords = {ords}
@@ -234,14 +233,14 @@ def do_zip_mods():
""")
# These encodings should match the list in tests/test_python.py
details = [
- (u'utf8', u'ⓗⓔⓛⓛⓞ, ⓦⓞⓡⓛⓓ'),
- (u'gb2312', u'你好,世界'),
- (u'hebrew', u'שלום, עולם'),
- (u'shift_jis', u'こんにちは世界'),
- (u'cp1252', u'“hi”'),
+ ('utf8', 'ⓗⓔⓛⓛⓞ, ⓦⓞⓡⓛⓓ'),
+ ('gb2312', '你好,世界'),
+ ('hebrew', 'שלום, עולם'),
+ ('shift_jis', 'こんにちは世界'),
+ ('cp1252', '“hi”'),
]
for encoding, text in details:
- filename = 'encoded_{}.py'.format(encoding)
+ filename = f'encoded_{encoding}.py'
ords = [ord(c) for c in text]
source_text = source.format(encoding=encoding, text=text, ords=ords)
zf.writestr(filename, source_text.encode(encoding))
@@ -291,7 +290,7 @@ def do_check_eol():
return
if line is not None and not line.strip():
- print("%s: final blank line" % (fname,))
+ print(f"{fname}: final blank line")
def check_files(root, patterns, **kwargs):
"""Check a number of files for whitespace abuse."""
@@ -339,7 +338,7 @@ def print_banner(label):
rev = platform.python_revision()
if rev:
- version += " (rev {})".format(rev)
+ version += f" (rev {rev})"
try:
which_python = os.path.relpath(sys.executable)
@@ -347,7 +346,7 @@ def print_banner(label):
# On Windows having a python executable on a different drive
# than the sources cannot be relative.
which_python = sys.executable
- print('=== %s %s %s (%s) ===' % (impl, version, label, which_python))
+ print(f'=== {impl} {version} {label} ({which_python}) ===')
sys.stdout.flush()
@@ -357,7 +356,7 @@ def do_help():
items.sort()
for name, value in items:
if name.startswith('do_'):
- print("%-20s%s" % (name[3:], value.__doc__))
+ print(f"{name[3:]:<20}{value.__doc__}")
def analyze_args(function):
diff --git a/setup.py b/setup.py
index ff261456..da2df88f 100644
--- a/setup.py
+++ b/setup.py
@@ -113,7 +113,7 @@ setup_args = dict(
# We need to get HTML assets from our htmlfiles directory.
zip_safe=False,
- author='Ned Batchelder and {} others'.format(num_others),
+ author=f'Ned Batchelder and {num_others} others',
author_email='ned@nedbatchelder.com',
description=doc,
long_description=long_description,
@@ -218,8 +218,8 @@ def main():
setup(**setup_args)
except BuildFailed as exc:
msg = "Couldn't install with extension module, trying without it..."
- exc_msg = "%s: %s" % (exc.__class__.__name__, exc.cause)
- print("**\n** %s\n** %s\n**" % (msg, exc_msg))
+ exc_msg = f"{exc.__class__.__name__}: {exc.cause}"
+ print(f"**\n** {msg}\n** {exc_msg}\n**")
del setup_args['ext_modules']
setup(**setup_args)