diff options
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/cmdline.py | 26 | ||||
-rw-r--r-- | coverage/collector.py | 4 | ||||
-rw-r--r-- | coverage/config.py | 6 | ||||
-rw-r--r-- | coverage/control.py | 4 |
4 files changed, 20 insertions, 20 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index cc7d8082..d1e8f283 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -46,8 +46,8 @@ class Opts: choices=CONCURRENCY_CHOICES, help=( "Properly measure code using a concurrency library. " - "Valid values are: %s." - ) % ", ".join(CONCURRENCY_CHOICES), + "Valid values are: {}." + ).format(", ".join(CONCURRENCY_CHOICES)), ) context = optparse.make_option( '', '--context', action='store', metavar="LABEL", @@ -299,7 +299,7 @@ class CmdOptionParser(CoverageOptionParser): def __eq__(self, other): # A convenience equality, so that I can put strings in unit test # results, and they will compare equal to objects. - return (other == "<CmdOptionParser:%s>" % self.cmd) + return (other == f"<CmdOptionParser:{self.cmd}>") __hash__ = None # This object doesn't need to be hashed. @@ -506,7 +506,7 @@ def show_help(error=None, topic=None, parser=None): if help_msg: print(help_msg.format(**help_params)) else: - print("Don't know topic %r" % topic) + print(f"Don't know topic {topic!r}") print("Full documentation is at {__url__}".format(**help_params)) @@ -541,7 +541,7 @@ class CoverageScript: else: parser = CMDS.get(argv[0]) if not parser: - show_help("Unknown command: '%s'" % argv[0]) + show_help(f"Unknown command: {argv[0]!r}") return ERR argv = argv[1:] @@ -765,22 +765,22 @@ class CoverageScript: sys_info = self.coverage.sys_info() print(info_header("sys")) for line in info_formatter(sys_info): - print(" %s" % line) + print(f" {line}") elif info == 'data': self.coverage.load() data = self.coverage.get_data() print(info_header("data")) - print("path: %s" % data.data_filename()) + print(f"path: {data.data_filename()}") if data: - print("has_arcs: %r" % data.has_arcs()) + print(f"has_arcs: {data.has_arcs()!r}") summary = line_counts(data, fullpath=True) filenames = sorted(summary.keys()) - print("\n%d files:" % len(filenames)) + print(f"\n{len(filenames)} files:") for f in filenames: - line = "%s: %d lines" % (f, summary[f]) + line = f"{f}: {summary[f]} lines" plugin = data.file_tracer(f) if plugin: - line += " [%s]" % plugin + line += f" [{plugin}]" print(line) else: print("No data collected") @@ -788,12 +788,12 @@ class CoverageScript: print(info_header("config")) config_info = self.coverage.config.__dict__.items() for line in info_formatter(config_info): - print(" %s" % line) + print(f" {line}") elif info == "premain": print(info_header("premain")) print(short_stack()) else: - show_help("Don't know what you mean by %r" % info) + show_help(f"Don't know what you mean by {info!r}") return ERR return OK diff --git a/coverage/collector.py b/coverage/collector.py index e219c928..f9e9d14f 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -116,7 +116,7 @@ class Collector: # We can handle a few concurrency options here, but only one at a time. these_concurrencies = self.SUPPORTED_CONCURRENCIES.intersection(concurrency) if len(these_concurrencies) > 1: - raise CoverageException("Conflicting concurrency settings: %s" % concurrency) + raise CoverageException(f"Conflicting concurrency settings: {concurrency}") self.concurrency = these_concurrencies.pop() if these_concurrencies else '' try: @@ -136,7 +136,7 @@ class Collector: import threading self.threading = threading else: - raise CoverageException("Don't understand concurrency=%s" % concurrency) + raise CoverageException(f"Don't understand concurrency={concurrency}") except ImportError: raise CoverageException( "Couldn't trace with concurrency={}, the module isn't installed.".format( diff --git a/coverage/config.py b/coverage/config.py index 71f8fbd0..44bae957 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -443,7 +443,7 @@ class CoverageConfig: return # If we get here, we didn't find the option. - raise CoverageException("No such option: %r" % option_name) + raise CoverageException(f"No such option: {option_name!r}") def get_option(self, option_name): """Get an option from the configuration. @@ -471,7 +471,7 @@ class CoverageConfig: return self.plugin_options.get(plugin_name, {}).get(key) # If we get here, we didn't find the option. - raise CoverageException("No such option: %r" % option_name) + raise CoverageException(f"No such option: {option_name!r}") def post_process_file(self, path): """Make final adjustments to a file path to make it usable.""" @@ -545,7 +545,7 @@ def read_coverage_config(config_file, **kwargs): if config_read: break if specified_file: - raise CoverageException("Couldn't read '%s' as a config file" % fname) + raise CoverageException(f"Couldn't read {fname!r} as a config file") # $set_env.py: COVERAGE_DEBUG - Options for --debug. # 3) from environment variables: diff --git a/coverage/control.py b/coverage/control.py index 95d22007..0ec9264c 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -361,8 +361,8 @@ class Coverage: if slug: msg = f"{msg} ({slug})" if self._debug.should('pid'): - msg = "[%d] %s" % (os.getpid(), msg) - sys.stderr.write("Coverage.py warning: %s\n" % msg) + msg = f"[{os.getpid()}] {msg}" + sys.stderr.write(f"Coverage.py warning: {msg}\n") if once: self._no_warn_slugs.append(slug) |