summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2023-03-22 14:28:42 -0400
committerNed Batchelder <ned@nedbatchelder.com>2023-03-22 15:05:23 -0400
commit16abd82b6e87753184e8308c4b2606ff3979f8d3 (patch)
tree288f6b82ebd9ee864a05db6e66980cc63e205b49
parent63f3e495b184ebd9aa4c9d757fb78ed148580d29 (diff)
downloadpython-coveragepy-git-16abd82b6e87753184e8308c4b2606ff3979f8d3.tar.gz
style: use double-quotes
-rw-r--r--coverage/annotate.py22
-rw-r--r--coverage/cmdline.py136
-rw-r--r--coverage/html.py106
-rw-r--r--coverage/jsonreport.py54
-rw-r--r--coverage/lcovreport.py2
-rw-r--r--coverage/summary.py12
-rw-r--r--coverage/xmlreport.py8
7 files changed, 170 insertions, 170 deletions
diff --git a/coverage/annotate.py b/coverage/annotate.py
index 13dbe9b6..b4a02cb4 100644
--- a/coverage/annotate.py
+++ b/coverage/annotate.py
@@ -40,8 +40,8 @@ class AnnotateReporter:
> h(2)
- Executed lines use '>', lines not executed use '!', lines excluded from
- consideration use '-'.
+ Executed lines use ">", lines not executed use "!", lines excluded from
+ consideration use "-".
"""
@@ -83,7 +83,7 @@ class AnnotateReporter:
else:
dest_file = fr.filename + ",cover"
- with open(dest_file, 'w', encoding='utf-8') as dest:
+ with open(dest_file, "w", encoding="utf-8") as dest:
i = j = 0
covered = True
source = fr.source()
@@ -95,20 +95,20 @@ class AnnotateReporter:
if i < len(statements) and statements[i] == lineno:
covered = j >= len(missing) or missing[j] > lineno
if self.blank_re.match(line):
- dest.write(' ')
+ dest.write(" ")
elif self.else_re.match(line):
- # Special logic for lines containing only 'else:'.
+ # Special logic for lines containing only "else:".
if j >= len(missing):
- dest.write('> ')
+ dest.write("> ")
elif statements[i] == missing[j]:
- dest.write('! ')
+ dest.write("! ")
else:
- dest.write('> ')
+ dest.write("> ")
elif lineno in excluded:
- dest.write('- ')
+ dest.write("- ")
elif covered:
- dest.write('> ')
+ dest.write("> ")
else:
- dest.write('! ')
+ dest.write("! ")
dest.write(line)
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index ef760a50..4498eeec 100644
--- a/coverage/cmdline.py
+++ b/coverage/cmdline.py
@@ -39,130 +39,130 @@ class Opts:
# appears on the command line.
append = optparse.make_option(
- '-a', '--append', action='store_true',
+ "-a", "--append", action="store_true",
help="Append coverage data to .coverage, otherwise it starts clean each time.",
)
keep = optparse.make_option(
- '', '--keep', action='store_true',
+ "", "--keep", action="store_true",
help="Keep original coverage files, otherwise they are deleted.",
)
branch = optparse.make_option(
- '', '--branch', action='store_true',
+ "", "--branch", action="store_true",
help="Measure branch coverage in addition to statement coverage.",
)
concurrency = optparse.make_option(
- '', '--concurrency', action='store', metavar="LIBS",
+ "", "--concurrency", action="store", metavar="LIBS",
help=(
"Properly measure code using a concurrency library. " +
"Valid values are: {}, or a comma-list of them."
).format(", ".join(sorted(CoverageConfig.CONCURRENCY_CHOICES))),
)
context = optparse.make_option(
- '', '--context', action='store', metavar="LABEL",
+ "", "--context", action="store", metavar="LABEL",
help="The context label to record for this coverage run.",
)
contexts = optparse.make_option(
- '', '--contexts', action='store', metavar="REGEX1,REGEX2,...",
+ "", "--contexts", action="store", metavar="REGEX1,REGEX2,...",
help=(
"Only display data from lines covered in the given contexts. " +
"Accepts Python regexes, which must be quoted."
),
)
combine_datafile = optparse.make_option(
- '', '--data-file', action='store', metavar="DATAFILE",
+ "", "--data-file", action="store", metavar="DATAFILE",
help=(
"Base name of the data files to operate on. " +
"Defaults to '.coverage'. [env: COVERAGE_FILE]"
),
)
input_datafile = optparse.make_option(
- '', '--data-file', action='store', metavar="INFILE",
+ "", "--data-file", action="store", metavar="INFILE",
help=(
"Read coverage data for report generation from this file. " +
"Defaults to '.coverage'. [env: COVERAGE_FILE]"
),
)
output_datafile = optparse.make_option(
- '', '--data-file', action='store', metavar="OUTFILE",
+ "", "--data-file", action="store", metavar="OUTFILE",
help=(
"Write the recorded coverage data to this file. " +
"Defaults to '.coverage'. [env: COVERAGE_FILE]"
),
)
debug = optparse.make_option(
- '', '--debug', action='store', metavar="OPTS",
+ "", "--debug", action="store", metavar="OPTS",
help="Debug options, separated by commas. [env: COVERAGE_DEBUG]",
)
directory = optparse.make_option(
- '-d', '--directory', action='store', metavar="DIR",
+ "-d", "--directory", action="store", metavar="DIR",
help="Write the output files to DIR.",
)
fail_under = optparse.make_option(
- '', '--fail-under', action='store', metavar="MIN", type="float",
+ "", "--fail-under", action="store", metavar="MIN", type="float",
help="Exit with a status of 2 if the total coverage is less than MIN.",
)
format = optparse.make_option(
- '', '--format', action='store', metavar="FORMAT",
+ "", "--format", action="store", metavar="FORMAT",
help="Output format, either text (default), markdown, or total.",
)
help = optparse.make_option(
- '-h', '--help', action='store_true',
+ "-h", "--help", action="store_true",
help="Get help on this command.",
)
ignore_errors = optparse.make_option(
- '-i', '--ignore-errors', action='store_true',
+ "-i", "--ignore-errors", action="store_true",
help="Ignore errors while reading source files.",
)
include = optparse.make_option(
- '', '--include', action='store', metavar="PAT1,PAT2,...",
+ "", "--include", action="store", metavar="PAT1,PAT2,...",
help=(
"Include only files whose paths match one of these patterns. " +
"Accepts shell-style wildcards, which must be quoted."
),
)
pylib = optparse.make_option(
- '-L', '--pylib', action='store_true',
+ "-L", "--pylib", action="store_true",
help=(
"Measure coverage even inside the Python installed library, " +
"which isn't done by default."
),
)
show_missing = optparse.make_option(
- '-m', '--show-missing', action='store_true',
+ "-m", "--show-missing", action="store_true",
help="Show line numbers of statements in each module that weren't executed.",
)
module = optparse.make_option(
- '-m', '--module', action='store_true',
+ "-m", "--module", action="store_true",
help=(
"<pyfile> is an importable Python module, not a script path, " +
"to be run as 'python -m' would run it."
),
)
omit = optparse.make_option(
- '', '--omit', action='store', metavar="PAT1,PAT2,...",
+ "", "--omit", action="store", metavar="PAT1,PAT2,...",
help=(
"Omit files whose paths match one of these patterns. " +
"Accepts shell-style wildcards, which must be quoted."
),
)
output_xml = optparse.make_option(
- '-o', '', action='store', dest="outfile", metavar="OUTFILE",
+ "-o", "", action="store", dest="outfile", metavar="OUTFILE",
help="Write the XML report to this file. Defaults to 'coverage.xml'",
)
output_json = optparse.make_option(
- '-o', '', action='store', dest="outfile", metavar="OUTFILE",
+ "-o", "", action="store", dest="outfile", metavar="OUTFILE",
help="Write the JSON report to this file. Defaults to 'coverage.json'",
)
output_lcov = optparse.make_option(
- '-o', '', action='store', dest='outfile', metavar="OUTFILE",
+ "-o", "", action="store", dest="outfile", metavar="OUTFILE",
help="Write the LCOV report to this file. Defaults to 'coverage.lcov'",
)
json_pretty_print = optparse.make_option(
- '', '--pretty-print', action='store_true',
+ "", "--pretty-print", action="store_true",
help="Format the JSON for human readers.",
)
parallel_mode = optparse.make_option(
- '-p', '--parallel-mode', action='store_true',
+ "-p", "--parallel-mode", action="store_true",
help=(
"Append the machine name, process id and random number to the " +
"data file name to simplify collecting data from " +
@@ -170,18 +170,18 @@ class Opts:
),
)
precision = optparse.make_option(
- '', '--precision', action='store', metavar='N', type=int,
+ "", "--precision", action="store", metavar="N", type=int,
help=(
"Number of digits after the decimal point to display for " +
"reported coverage percentages."
),
)
quiet = optparse.make_option(
- '-q', '--quiet', action='store_true',
+ "-q", "--quiet", action="store_true",
help="Don't print messages about what is happening.",
)
rcfile = optparse.make_option(
- '', '--rcfile', action='store',
+ "", "--rcfile", action="store",
help=(
"Specify configuration file. " +
"By default '.coveragerc', 'setup.cfg', 'tox.ini', and " +
@@ -189,45 +189,45 @@ class Opts:
),
)
show_contexts = optparse.make_option(
- '--show-contexts', action='store_true',
+ "--show-contexts", action="store_true",
help="Show contexts for covered lines.",
)
skip_covered = optparse.make_option(
- '--skip-covered', action='store_true',
+ "--skip-covered", action="store_true",
help="Skip files with 100% coverage.",
)
no_skip_covered = optparse.make_option(
- '--no-skip-covered', action='store_false', dest='skip_covered',
+ "--no-skip-covered", action="store_false", dest="skip_covered",
help="Disable --skip-covered.",
)
skip_empty = optparse.make_option(
- '--skip-empty', action='store_true',
+ "--skip-empty", action="store_true",
help="Skip files with no code.",
)
sort = optparse.make_option(
- '--sort', action='store', metavar='COLUMN',
+ "--sort", action="store", metavar="COLUMN",
help=(
"Sort the report by the named column: name, stmts, miss, branch, brpart, or cover. " +
"Default is name."
),
)
source = optparse.make_option(
- '', '--source', action='store', metavar="SRC1,SRC2,...",
+ "", "--source", action="store", metavar="SRC1,SRC2,...",
help="A list of directories or importable names of code to measure.",
)
timid = optparse.make_option(
- '', '--timid', action='store_true',
+ "", "--timid", action="store_true",
help=(
"Use a simpler but slower trace method. Try this if you get " +
"seemingly impossible results!"
),
)
title = optparse.make_option(
- '', '--title', action='store', metavar="TITLE",
+ "", "--title", action="store", metavar="TITLE",
help="A text string to use as the title on the HTML.",
)
version = optparse.make_option(
- '', '--version', action='store_true',
+ "", "--version", action="store_true",
help="Display version information and exit.",
)
@@ -369,7 +369,7 @@ GLOBAL_ARGS = [
]
COMMANDS = {
- 'annotate': CmdOptionParser(
+ "annotate": CmdOptionParser(
"annotate",
[
Opts.directory,
@@ -385,7 +385,7 @@ COMMANDS = {
),
),
- 'combine': CmdOptionParser(
+ "combine": CmdOptionParser(
"combine",
[
Opts.append,
@@ -404,7 +404,7 @@ COMMANDS = {
),
),
- 'debug': CmdOptionParser(
+ "debug": CmdOptionParser(
"debug", GLOBAL_ARGS,
usage="<topic>",
description=(
@@ -419,7 +419,7 @@ COMMANDS = {
),
),
- 'erase': CmdOptionParser(
+ "erase": CmdOptionParser(
"erase",
[
Opts.combine_datafile
@@ -427,13 +427,13 @@ COMMANDS = {
description="Erase previously collected coverage data.",
),
- 'help': CmdOptionParser(
+ "help": CmdOptionParser(
"help", GLOBAL_ARGS,
usage="[command]",
description="Describe how to use coverage.py",
),
- 'html': CmdOptionParser(
+ "html": CmdOptionParser(
"html",
[
Opts.contexts,
@@ -459,7 +459,7 @@ COMMANDS = {
),
),
- 'json': CmdOptionParser(
+ "json": CmdOptionParser(
"json",
[
Opts.contexts,
@@ -477,7 +477,7 @@ COMMANDS = {
description="Generate a JSON report of coverage results.",
),
- 'lcov': CmdOptionParser(
+ "lcov": CmdOptionParser(
"lcov",
[
Opts.input_datafile,
@@ -492,7 +492,7 @@ COMMANDS = {
description="Generate an LCOV report of coverage results.",
),
- 'report': CmdOptionParser(
+ "report": CmdOptionParser(
"report",
[
Opts.contexts,
@@ -513,7 +513,7 @@ COMMANDS = {
description="Report coverage statistics on modules.",
),
- 'run': CmdOptionParser(
+ "run": CmdOptionParser(
"run",
[
Opts.append,
@@ -533,7 +533,7 @@ COMMANDS = {
description="Run a Python program, measuring code execution.",
),
- 'xml': CmdOptionParser(
+ "xml": CmdOptionParser(
"xml",
[
Opts.input_datafile,
@@ -560,12 +560,12 @@ def show_help(
assert error or topic or parser
program_path = sys.argv[0]
- if program_path.endswith(os.path.sep + '__main__.py'):
+ if program_path.endswith(os.path.sep + "__main__.py"):
# The path is the main module of a package; get that path instead.
program_path = os.path.dirname(program_path)
program_name = os.path.basename(program_path)
if env.WINDOWS:
- # entry_points={'console_scripts':...} on Windows makes files
+ # entry_points={"console_scripts":...} on Windows makes files
# called coverage.exe, coverage3.exe, and coverage-3.5.exe. These
# invoke coverage-script.py, coverage3-script.py, and
# coverage-3.5-script.py. argv[0] is the .py file, but we want to
@@ -576,11 +576,11 @@ def show_help(
help_params = dict(coverage.__dict__)
help_params["__url__"] = __url__
- help_params['program_name'] = program_name
+ help_params["program_name"] = program_name
if HAS_CTRACER:
- help_params['extension_modifier'] = 'with C extension'
+ help_params["extension_modifier"] = "with C extension"
else:
- help_params['extension_modifier'] = 'without C extension'
+ help_params["extension_modifier"] = "without C extension"
if error:
print(error, file=sys.stderr)
@@ -590,7 +590,7 @@ def show_help(
print()
else:
assert topic is not None
- help_msg = textwrap.dedent(HELP_TOPICS.get(topic, '')).strip()
+ help_msg = textwrap.dedent(HELP_TOPICS.get(topic, "")).strip()
if help_msg:
print(help_msg.format(**help_params))
else:
@@ -618,13 +618,13 @@ class CoverageScript:
"""
# Collect the command-line options.
if not argv:
- show_help(topic='minimum_help')
+ show_help(topic="minimum_help")
return OK
# The command syntax we parse depends on the first argument. Global
# switch syntax always starts with an option.
parser: Optional[optparse.OptionParser]
- self.global_option = argv[0].startswith('-')
+ self.global_option = argv[0].startswith("-")
if self.global_option:
parser = GlobalOptionParser()
else:
@@ -702,7 +702,7 @@ class CoverageScript:
# We need to be able to import from the current directory, because
# plugins may try to, for example, to read Django settings.
- sys.path.insert(0, '')
+ sys.path.insert(0, "")
self.coverage.load()
@@ -786,7 +786,7 @@ class CoverageScript:
# Handle help.
if options.help:
if self.global_option:
- show_help(topic='help')
+ show_help(topic="help")
else:
show_help(parser=parser)
return True
@@ -800,12 +800,12 @@ class CoverageScript:
else:
show_help(topic=a)
else:
- show_help(topic='help')
+ show_help(topic="help")
return True
# Handle version.
if options.version:
- show_help(topic='version')
+ show_help(topic="version")
return True
return False
@@ -835,7 +835,7 @@ class CoverageScript:
if options.concurrency == "multiprocessing":
# Can't set other run-affecting command line options with
# multiprocessing.
- for opt_name in ['branch', 'include', 'omit', 'pylib', 'source', 'timid']:
+ for opt_name in ["branch", "include", "omit", "pylib", "source", "timid"]:
# As it happens, all of these options have no default, meaning
# they will be None if they have not been specified.
if getattr(options, opt_name) is not None:
@@ -913,7 +913,7 @@ def unshell_list(s: str) -> Optional[List[str]]:
# line, but (not) helpfully, the single quotes are included in the
# argument, so we have to strip them off here.
s = s.strip("'")
- return s.split(',')
+ return s.split(",")
def unglob_args(args: List[str]) -> List[str]:
@@ -921,7 +921,7 @@ def unglob_args(args: List[str]) -> List[str]:
if env.WINDOWS:
globbed = []
for arg in args:
- if '?' in arg or '*' in arg:
+ if "?" in arg or "*" in arg:
globbed.extend(glob.glob(arg))
else:
globbed.append(arg)
@@ -930,7 +930,7 @@ def unglob_args(args: List[str]) -> List[str]:
HELP_TOPICS = {
- 'help': """\
+ "help": """\
Coverage.py, version {__version__} {extension_modifier}
Measure, collect, and report on code coverage in Python programs.
@@ -952,11 +952,11 @@ HELP_TOPICS = {
Use "{program_name} help <command>" for detailed help on any command.
""",
- 'minimum_help': """\
+ "minimum_help": """\
Code coverage for Python, version {__version__} {extension_modifier}. Use '{program_name} help' for help.
""",
- 'version': """\
+ "version": """\
Coverage.py, version {__version__} {extension_modifier}
""",
}
@@ -1008,6 +1008,6 @@ if _profile: # pragma: debugging
try:
return original_main(argv)
finally:
- data, _ = profiler.query(re_filter='coverage', max_records=100)
- print(profiler.show(query=data, limit=100, sep='', col=''))
+ data, _ = profiler.query(re_filter="coverage", max_records=100)
+ print(profiler.show(query=data, limit=100, sep="", col=""))
profiler.cancel()
diff --git a/coverage/html.py b/coverage/html.py
index d172e896..d1a90ecd 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -69,7 +69,7 @@ def write_html(fname: str, html: str) -> None:
"""Write `html` to `fname`, properly encoded."""
html = re.sub(r"(\A\s+)|(\s+$)", "", html, flags=re.MULTILINE) + "\n"
with open(fname, "wb") as fout:
- fout.write(html.encode('ascii', 'xmlcharrefreplace'))
+ fout.write(html.encode("ascii", "xmlcharrefreplace"))
@dataclass
@@ -132,11 +132,11 @@ class HtmlDataGeneration:
long_annotations = []
if lineno in analysis.excluded:
- category = 'exc'
+ category = "exc"
elif lineno in analysis.missing:
- category = 'mis'
+ category = "mis"
elif self.has_arcs and lineno in missing_branch_arcs:
- category = 'par'
+ category = "par"
for b in missing_branch_arcs[lineno]:
if b < 0:
short_annotations.append("exit")
@@ -144,7 +144,7 @@ class HtmlDataGeneration:
short_annotations.append(str(b))
long_annotations.append(fr.missing_arc_description(lineno, b, arcs_executed))
elif lineno in analysis.statements:
- category = 'run'
+ category = "run"
contexts = []
contexts_label = ""
@@ -236,26 +236,26 @@ class HtmlReporter:
self.template_globals = {
# Functions available in the templates.
- 'escape': escape,
- 'pair': pair,
- 'len': len,
+ "escape": escape,
+ "pair": pair,
+ "len": len,
# Constants for this report.
- '__url__': __url__,
- '__version__': coverage.__version__,
- 'title': title,
- 'time_stamp': format_local_datetime(datetime.datetime.now()),
- 'extra_css': self.extra_css,
- 'has_arcs': self.has_arcs,
- 'show_contexts': self.config.show_contexts,
+ "__url__": __url__,
+ "__version__": coverage.__version__,
+ "title": title,
+ "time_stamp": format_local_datetime(datetime.datetime.now()),
+ "extra_css": self.extra_css,
+ "has_arcs": self.has_arcs,
+ "show_contexts": self.config.show_contexts,
# Constants for all reports.
# These css classes determine which lines are highlighted by default.
- 'category': {
- 'exc': 'exc show_exc',
- 'mis': 'mis show_mis',
- 'par': 'par run show_par',
- 'run': 'run',
+ "category": {
+ "exc": "exc show_exc",
+ "mis": "mis show_mis",
+ "par": "par run show_par",
+ "run": "run",
},
}
self.pyfile_html_source = read_data("pyfile.html")
@@ -384,9 +384,9 @@ class HtmlReporter:
if tok_type == "ws":
html_parts.append(escape(tok_text))
else:
- tok_html = escape(tok_text) or '&nbsp;'
+ tok_html = escape(tok_text) or "&nbsp;"
html_parts.append(f'<span class="{tok_type}">{tok_html}</span>')
- ldata.html = ''.join(html_parts)
+ ldata.html = "".join(html_parts)
ldata.context_str = ",".join(
str(context_codes[c_context]) for c_context in ldata.context_list
)
@@ -419,24 +419,24 @@ class HtmlReporter:
css_classes = []
if ldata.category:
css_classes.append(
- self.template_globals['category'][ldata.category] # type: ignore[index]
+ self.template_globals["category"][ldata.category] # type: ignore[index]
)
- ldata.css_class = ' '.join(css_classes) or "pln"
+ ldata.css_class = " ".join(css_classes) or "pln"
html_path = os.path.join(self.directory, ftr.html_filename)
html = self.source_tmpl.render({
**file_data.__dict__,
"contexts_json": contexts_json,
- 'prev_html': prev_html,
- 'next_html': next_html,
+ "prev_html": prev_html,
+ "next_html": next_html,
})
write_html(html_path, html)
# Save this file's information for the index file.
index_info: IndexInfoDict = {
- 'nums': ftr.analysis.numbers,
- 'html_filename': ftr.html_filename,
- 'relative_filename': ftr.fr.relative_filename(),
+ "nums": ftr.analysis.numbers,
+ "html_filename": ftr.html_filename,
+ "relative_filename": ftr.fr.relative_filename(),
}
self.file_summaries.append(index_info)
self.incr.set_index_info(ftr.rootname, index_info)
@@ -455,12 +455,12 @@ class HtmlReporter:
skipped_empty_msg = f"{n} empty file{plural(n)} skipped."
html = index_tmpl.render({
- 'files': self.file_summaries,
- 'totals': self.totals,
- 'skipped_covered_msg': skipped_covered_msg,
- 'skipped_empty_msg': skipped_empty_msg,
- 'first_html': first_html,
- 'final_html': final_html,
+ "files": self.file_summaries,
+ "totals": self.totals,
+ "skipped_covered_msg": skipped_covered_msg,
+ "skipped_empty_msg": skipped_empty_msg,
+ "first_html": first_html,
+ "final_html": final_html,
})
index_file = os.path.join(self.directory, "index.html")
@@ -510,7 +510,7 @@ class IncrementalChecker:
def reset(self) -> None:
"""Initialize to empty. Causes all files to be reported."""
- self.globals = ''
+ self.globals = ""
self.files: Dict[str, FileInfoDict] = {}
def read(self) -> None:
@@ -524,17 +524,17 @@ class IncrementalChecker:
usable = False
else:
usable = True
- if status['format'] != self.STATUS_FORMAT:
+ if status["format"] != self.STATUS_FORMAT:
usable = False
- elif status['version'] != coverage.__version__:
+ elif status["version"] != coverage.__version__:
usable = False
if usable:
self.files = {}
- for filename, fileinfo in status['files'].items():
- fileinfo['index']['nums'] = Numbers(*fileinfo['index']['nums'])
+ for filename, fileinfo in status["files"].items():
+ fileinfo["index"]["nums"] = Numbers(*fileinfo["index"]["nums"])
self.files[filename] = fileinfo
- self.globals = status['globals']
+ self.globals = status["globals"]
else:
self.reset()
@@ -543,18 +543,18 @@ class IncrementalChecker:
status_file = os.path.join(self.directory, self.STATUS_FILE)
files = {}
for filename, fileinfo in self.files.items():
- index = fileinfo['index']
- index['nums'] = index['nums'].init_args() # type: ignore[typeddict-item]
+ index = fileinfo["index"]
+ index["nums"] = index["nums"].init_args() # type: ignore[typeddict-item]
files[filename] = fileinfo
status = {
- 'format': self.STATUS_FORMAT,
- 'version': coverage.__version__,
- 'globals': self.globals,
- 'files': files,
+ "format": self.STATUS_FORMAT,
+ "version": coverage.__version__,
+ "globals": self.globals,
+ "files": files,
}
with open(status_file, "w") as fout:
- json.dump(status, fout, separators=(',', ':'))
+ json.dump(status, fout, separators=(",", ":"))
def check_global_data(self, *data: Any) -> None:
"""Check the global data that can affect incremental reporting."""
@@ -573,7 +573,7 @@ class IncrementalChecker:
`rootname` is the name being used for the file.
"""
m = Hasher()
- m.update(fr.source().encode('utf-8'))
+ m.update(fr.source().encode("utf-8"))
add_data_to_hash(data, fr.filename, m)
this_hash = m.hexdigest()
@@ -588,19 +588,19 @@ class IncrementalChecker:
def file_hash(self, fname: str) -> str:
"""Get the hash of `fname`'s contents."""
- return self.files.get(fname, {}).get('hash', '') # type: ignore[call-overload]
+ return self.files.get(fname, {}).get("hash", "") # type: ignore[call-overload]
def set_file_hash(self, fname: str, val: str) -> None:
"""Set the hash of `fname`'s contents."""
- self.files.setdefault(fname, {})['hash'] = val # type: ignore[typeddict-item]
+ self.files.setdefault(fname, {})["hash"] = val # type: ignore[typeddict-item]
def index_info(self, fname: str) -> IndexInfoDict:
"""Get the information for index.html for `fname`."""
- return self.files.get(fname, {}).get('index', {}) # type: ignore
+ return self.files.get(fname, {}).get("index", {}) # type: ignore
def set_index_info(self, fname: str, info: IndexInfoDict) -> None:
"""Set the information for index.html for `fname`."""
- self.files.setdefault(fname, {})['index'] = info # type: ignore[typeddict-item]
+ self.files.setdefault(fname, {})["index"] = info # type: ignore[typeddict-item]
# Helpers for templates and generating HTML
diff --git a/coverage/jsonreport.py b/coverage/jsonreport.py
index 7ee1fb99..24e33585 100644
--- a/coverage/jsonreport.py
+++ b/coverage/jsonreport.py
@@ -60,20 +60,20 @@ class JsonReporter:
self.report_data["files"] = measured_files
self.report_data["totals"] = {
- 'covered_lines': self.total.n_executed,
- 'num_statements': self.total.n_statements,
- 'percent_covered': self.total.pc_covered,
- 'percent_covered_display': self.total.pc_covered_str,
- 'missing_lines': self.total.n_missing,
- 'excluded_lines': self.total.n_excluded,
+ "covered_lines": self.total.n_executed,
+ "num_statements": self.total.n_statements,
+ "percent_covered": self.total.pc_covered,
+ "percent_covered_display": self.total.pc_covered_str,
+ "missing_lines": self.total.n_missing,
+ "excluded_lines": self.total.n_excluded,
}
if coverage_data.has_arcs():
self.report_data["totals"].update({
- 'num_branches': self.total.n_branches,
- 'num_partial_branches': self.total.n_partial_branches,
- 'covered_branches': self.total.n_executed_branches,
- 'missing_branches': self.total.n_missing_branches,
+ "num_branches": self.total.n_branches,
+ "num_partial_branches": self.total.n_partial_branches,
+ "covered_branches": self.total.n_executed_branches,
+ "missing_branches": self.total.n_missing_branches,
})
json.dump(
@@ -89,32 +89,32 @@ class JsonReporter:
nums = analysis.numbers
self.total += nums
summary = {
- 'covered_lines': nums.n_executed,
- 'num_statements': nums.n_statements,
- 'percent_covered': nums.pc_covered,
- 'percent_covered_display': nums.pc_covered_str,
- 'missing_lines': nums.n_missing,
- 'excluded_lines': nums.n_excluded,
+ "covered_lines": nums.n_executed,
+ "num_statements": nums.n_statements,
+ "percent_covered": nums.pc_covered,
+ "percent_covered_display": nums.pc_covered_str,
+ "missing_lines": nums.n_missing,
+ "excluded_lines": nums.n_excluded,
}
reported_file = {
- 'executed_lines': sorted(analysis.executed),
- 'summary': summary,
- 'missing_lines': sorted(analysis.missing),
- 'excluded_lines': sorted(analysis.excluded),
+ "executed_lines": sorted(analysis.executed),
+ "summary": summary,
+ "missing_lines": sorted(analysis.missing),
+ "excluded_lines": sorted(analysis.excluded),
}
if self.config.json_show_contexts:
- reported_file['contexts'] = analysis.data.contexts_by_lineno(analysis.filename)
+ reported_file["contexts"] = analysis.data.contexts_by_lineno(analysis.filename)
if coverage_data.has_arcs():
summary.update({
- 'num_branches': nums.n_branches,
- 'num_partial_branches': nums.n_partial_branches,
- 'covered_branches': nums.n_executed_branches,
- 'missing_branches': nums.n_missing_branches,
+ "num_branches": nums.n_branches,
+ "num_partial_branches": nums.n_partial_branches,
+ "covered_branches": nums.n_executed_branches,
+ "missing_branches": nums.n_missing_branches,
})
- reported_file['executed_branches'] = list(
+ reported_file["executed_branches"] = list(
_convert_branch_arcs(analysis.executed_branch_arcs())
)
- reported_file['missing_branches'] = list(
+ reported_file["missing_branches"] = list(
_convert_branch_arcs(analysis.missing_branch_arcs())
)
return reported_file
diff --git a/coverage/lcovreport.py b/coverage/lcovreport.py
index 1789c17e..7d72e813 100644
--- a/coverage/lcovreport.py
+++ b/coverage/lcovreport.py
@@ -33,7 +33,7 @@ class LcovReporter:
def report(self, morfs: Optional[Iterable[TMorf]], outfile: IO[str]) -> float:
"""Renders the full lcov report.
- 'morfs' is a list of modules or filenames
+ `morfs` is a list of modules or filenames
outfile is the file object to write the file into.
"""
diff --git a/coverage/summary.py b/coverage/summary.py
index c4c7fd1d..5d373ec5 100644
--- a/coverage/summary.py
+++ b/coverage/summary.py
@@ -137,8 +137,8 @@ class SummaryReporter:
max_n = max(len(total_line[header.index("Cover")]) + 6, len(" Cover "))
header_items = [formats[item].format(item, name_len=max_name, n=max_n) for item in header]
header_str = "".join(header_items)
- rule_str = "|" + " ".join(["- |".rjust(len(header_items[0])-1, '-')] +
- ["-: |".rjust(len(item)-1, '-') for item in header_items[1:]]
+ rule_str = "|" + " ".join(["- |".rjust(len(header_items[0])-1, "-")] +
+ ["-: |".rjust(len(item)-1, "-") for item in header_items[1:]]
)
# Write the header
@@ -223,10 +223,10 @@ class SummaryReporter:
# Line sorting.
sort_option = (self.config.sort or "name").lower()
reverse = False
- if sort_option[0] == '-':
+ if sort_option[0] == "-":
reverse = True
sort_option = sort_option[1:]
- elif sort_option[0] == '+':
+ elif sort_option[0] == "+":
sort_option = sort_option[1:]
sort_idx = column_order.get(sort_option)
if sort_idx is None:
@@ -250,12 +250,12 @@ class SummaryReporter:
# Create other final lines.
end_lines = []
if self.config.skip_covered and self.skipped_count:
- file_suffix = 's' if self.skipped_count>1 else ''
+ file_suffix = "s" if self.skipped_count>1 else ""
end_lines.append(
f"\n{self.skipped_count} file{file_suffix} skipped due to complete coverage."
)
if self.config.skip_empty and self.empty_count:
- file_suffix = 's' if self.empty_count > 1 else ''
+ file_suffix = "s" if self.empty_count > 1 else ""
end_lines.append(f"\n{self.empty_count} empty file{file_suffix} skipped.")
if self.output_format == "markdown":
diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py
index fd2e9f81..2c8fd0cc 100644
--- a/coverage/xmlreport.py
+++ b/coverage/xmlreport.py
@@ -28,7 +28,7 @@ if TYPE_CHECKING:
os = isolate_module(os)
-DTD_URL = 'https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd'
+DTD_URL = "https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd"
def rate(hit: int, num: int) -> str:
@@ -127,7 +127,7 @@ class XmlReporter:
appendChild(xpackage, xclasses)
for _, class_elt in human_sorted_items(pkg_data.elements.items()):
appendChild(xclasses, class_elt)
- xpackage.setAttribute("name", pkg_name.replace(os.sep, '.'))
+ xpackage.setAttribute("name", pkg_name.replace(os.sep, "."))
xpackage.setAttribute("line-rate", rate(pkg_data.hits, pkg_data.lines))
if has_arcs:
branch_rate = rate(pkg_data.br_hits, pkg_data.branches)
@@ -172,7 +172,7 @@ class XmlReporter:
if analysis.numbers.n_statements == 0:
return
- # Create the 'lines' and 'package' XML elements, which
+ # Create the "lines" and "package" XML elements, which
# are populated later. Note that a package == a directory.
filename = fr.filename.replace("\\", "/")
for source_path in self.source_paths:
@@ -205,7 +205,7 @@ class XmlReporter:
branch_stats = analysis.branch_stats()
missing_branch_arcs = analysis.missing_branch_arcs()
- # For each statement, create an XML 'line' element.
+ # For each statement, create an XML "line" element.
for line in sorted(analysis.statements):
xline = self.xml_out.createElement("line")
xline.setAttribute("number", str(line))