Skip to content

Commit

Permalink
style: parens should indent the same as their opening line
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed May 1, 2022
1 parent 53f00a0 commit 420c013
Show file tree
Hide file tree
Showing 43 changed files with 164 additions and 166 deletions.
2 changes: 1 addition & 1 deletion ci/comment_on_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
comment = (
f"This is now released as part of [coverage {version}]" +
f"(https://pypi.org/project/coverage/{version})."
)
)
print(f"Comment will be: {comment}")

owner = "nedbat"
Expand Down
24 changes: 11 additions & 13 deletions coverage/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ class CoverageOptionParser(optparse.OptionParser):
"""

def __init__(self, *args, **kwargs):
super().__init__(
add_help_option=False, *args, **kwargs
)
super().__init__(add_help_option=False, *args, **kwargs)
self.set_defaults(
# Keep these arguments alphabetized by their names.
action=None,
Expand Down Expand Up @@ -267,7 +265,7 @@ def __init__(self, *args, **kwargs):
timid=None,
title=None,
version=None,
)
)

self.disable_interspersed_args()

Expand Down Expand Up @@ -352,7 +350,7 @@ def get_prog_name(self):
Opts.debug,
Opts.help,
Opts.rcfile,
]
]

COMMANDS = {
'annotate': CmdOptionParser(
Expand Down Expand Up @@ -473,7 +471,7 @@ def get_prog_name(self):
Opts.output_lcov,
Opts.omit,
Opts.quiet,
] + GLOBAL_ARGS,
] + GLOBAL_ARGS,
usage="[options] [modules]",
description="Generate an LCOV report of coverage results.",
),
Expand Down Expand Up @@ -648,7 +646,7 @@ def command_line(self, argv):
check_preimported=True,
context=options.context,
messages=not options.quiet,
)
)

if options.action == "debug":
return self.do_debug(args)
Expand All @@ -675,7 +673,7 @@ def command_line(self, argv):
omit=omit,
include=include,
contexts=contexts,
)
)

# We need to be able to import from the current directory, because
# plugins may try to, for example, to read Django settings.
Expand All @@ -692,7 +690,7 @@ def command_line(self, argv):
skip_empty=options.skip_empty,
sort=options.sort,
**report_args
)
)
elif options.action == "annotate":
self.coverage.annotate(directory=options.directory, **report_args)
elif options.action == "html":
Expand All @@ -704,25 +702,25 @@ def command_line(self, argv):
show_contexts=options.show_contexts,
title=options.title,
**report_args
)
)
elif options.action == "xml":
total = self.coverage.xml_report(
outfile=options.outfile,
skip_empty=options.skip_empty,
**report_args
)
)
elif options.action == "json":
total = self.coverage.json_report(
outfile=options.outfile,
pretty_print=options.pretty_print,
show_contexts=options.show_contexts,
**report_args
)
)
elif options.action == "lcov":
total = self.coverage.lcov_report(
outfile=options.outfile,
**report_args
)
)
else:
# There are no other possible actions.
raise AssertionError
Expand Down
2 changes: 1 addition & 1 deletion coverage/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def debug_info(self):
"""Make a list of (name, value) pairs for writing debug info."""
return human_sorted_items(
(k, v) for k, v in self.__dict__.items() if not k.startswith("_")
)
)


def config_files_to_try(config_file):
Expand Down
12 changes: 6 additions & 6 deletions coverage/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def __init__(
source=source, source_pkgs=source_pkgs, run_omit=omit, run_include=include, debug=debug,
report_omit=omit, report_include=include,
concurrency=concurrency, context=context,
)
)

# If we have sub-process measurement happening automatically, then we
# want any explicit creation of a Coverage object to mean, this process
Expand Down Expand Up @@ -489,7 +489,7 @@ def _init_for_start(self):
branch=self.config.branch,
warn=self._warn,
concurrency=concurrency,
)
)

suffix = self._data_suffix_specified
if suffix:
Expand All @@ -515,10 +515,10 @@ def _init_for_start(self):
", ".join(
plugin._coverage_plugin_name
for plugin in self._plugins.file_tracers
),
),
self._collector.tracer_name(),
)
)
)
for plugin in self._plugins.file_tracers:
plugin._coverage_enabled = False

Expand Down Expand Up @@ -835,7 +835,7 @@ def analysis2(self, morf):
sorted(analysis.excluded),
sorted(analysis.missing),
analysis.missing_formatted(),
)
)

def _analyze(self, it):
"""Analyze a single morf or code unit.
Expand Down Expand Up @@ -1146,7 +1146,7 @@ def plugin_info(plugins):
)
)),
('command_line', " ".join(getattr(sys, 'argv', ['-none-']))),
]
]

if self._inorout:
info.extend(self._inorout.sys_info())
Expand Down
2 changes: 1 addition & 1 deletion coverage/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def __repr__(self):
klass=self.__class__.__name__,
id=id(self),
attrs=" ".join(f"{k}={v!r}" for k, v in show_attrs),
)
)


def simplify(v): # pragma: debugging
Expand Down
6 changes: 3 additions & 3 deletions coverage/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def __init__(self, cov):
'mis': 'mis show_mis',
'par': 'par run show_par',
'run': 'run',
}
},
}
self.pyfile_html_source = read_data("pyfile.html")
self.source_tmpl = Templite(self.pyfile_html_source, self.template_globals)
Expand Down Expand Up @@ -292,7 +292,7 @@ def html_file(self, fr, analysis):
ldata.annotate = ",   ".join(
f"{ldata.number} ↛ {d}"
for d in ldata.short_annotations
)
)
else:
ldata.annotate = None

Expand All @@ -306,7 +306,7 @@ def html_file(self, fr, analysis):
", ".join(
f"{num:d}) {ann_long}"
for num, ann_long in enumerate(longs, start=1)
),
),
)
else:
ldata.annotate_long = None
Expand Down
2 changes: 1 addition & 1 deletion coverage/inorout.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def sys_info(self):
'source_match', 'source_pkgs_match',
'include_match', 'omit_match',
'cover_match', 'pylib_match', 'third_match',
]
]

for matcher_name in matcher_names:
matcher = getattr(self, matcher_name)
Expand Down
2 changes: 1 addition & 1 deletion coverage/jsonreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def report(self, morfs, outfile=None):
json.dump(
self.report_data,
outfile,
indent=4 if self.config.json_pretty_print else None
indent=(4 if self.config.json_pretty_print else None),
)

return self.total.n_statements and self.total.pc_covered
Expand Down
2 changes: 1 addition & 1 deletion coverage/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _needs_to_implement(that, func_name):

raise NotImplementedError(
f"{thing} {name!r} needs to implement {func_name}()"
)
)


class DefaultValue:
Expand Down
6 changes: 3 additions & 3 deletions coverage/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,15 +1231,15 @@ def _handle__With(self, node):
if with_block.break_from:
self.process_break_exits(
self._combine_finally_starts(with_block.break_from, with_exit)
)
)
if with_block.continue_from:
self.process_continue_exits(
self._combine_finally_starts(with_block.continue_from, with_exit)
)
)
if with_block.return_from:
self.process_return_exits(
self._combine_finally_starts(with_block.return_from, with_exit)
)
)
return exits

_handle__AsyncWith = _handle__With
Expand Down
2 changes: 1 addition & 1 deletion coverage/phystokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def phys_tokens(toks):
99999, "\\\n",
(slineno, ccol), (slineno, ccol+2),
last_line
)
)
last_line = ltext
if ttype not in (tokenize.NEWLINE, tokenize.NL):
last_ttext = ttext
Expand Down
4 changes: 2 additions & 2 deletions coverage/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ def translate_arcs(self, arcs):
def no_branch_lines(self):
no_branch = self.parser.lines_matching(
join_regex(self.coverage.config.partial_list),
join_regex(self.coverage.config.partial_always_list)
)
join_regex(self.coverage.config.partial_always_list),
)
return no_branch

@expensive
Expand Down
4 changes: 2 additions & 2 deletions coverage/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ def __add__(self, other):
nums.n_branches = self.n_branches + other.n_branches
nums.n_partial_branches = (
self.n_partial_branches + other.n_partial_branches
)
)
nums.n_missing_branches = (
self.n_missing_branches + other.n_missing_branches
)
)
return nums

def __radd__(self, other):
Expand Down
6 changes: 3 additions & 3 deletions coverage/sqldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def update(self, other_data, aliases=None):
"from line_bits " +
"inner join file on file.id = line_bits.file_id " +
"inner join context on context.id = line_bits.context_id"
)
)
lines = {(files[path], context): numbits for (path, context, numbits) in cur}
cur.close()

Expand Down Expand Up @@ -720,7 +720,7 @@ def update(self, other_data, aliases=None):
"from line_bits " +
"inner join file on file.id = line_bits.file_id " +
"inner join context on context.id = line_bits.context_id"
)
)
for path, context, numbits in cur:
key = (aliases.map(path), context)
if key in lines:
Expand Down Expand Up @@ -977,7 +977,7 @@ def contexts_by_lineno(self, filename):
"select l.numbits, c.context from line_bits l, context c " +
"where l.context_id = c.id " +
"and file_id = ?"
)
)
data = [file_id]
if self._query_context_ids is not None:
ids_array = ", ".join("?" * len(self._query_context_ids))
Expand Down
4 changes: 2 additions & 2 deletions coverage/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ def report(self, morfs, outfile=None):
if self.config.skip_covered and self.skipped_count:
self.writeout(
fmt_skip_covered % (self.skipped_count, 's' if self.skipped_count > 1 else '')
)
)
if self.config.skip_empty and self.empty_count:
self.writeout(
fmt_skip_empty % (self.empty_count, 's' if self.empty_count > 1 else '')
)
)

return self.total.n_statements and self.total.pc_covered

Expand Down
4 changes: 2 additions & 2 deletions coverage/xmlreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def report(self, morfs, outfile=None):
xcoverage.setAttribute("timestamp", str(int(time.time()*1000)))
xcoverage.appendChild(self.xml_out.createComment(
f" Generated by coverage.py: {__url__} "
))
))
xcoverage.appendChild(self.xml_out.createComment(f" Based on {DTD_URL} "))

# Call xml_file for each file in the data.
Expand Down Expand Up @@ -193,7 +193,7 @@ def xml_file(self, fr, analysis, has_arcs):
xline.setAttribute(
"condition-coverage",
"%d%% (%d/%d)" % (100*taken//total, taken, total)
)
)
if line in missing_branch_arcs:
annlines = ["exit" if b < 0 else str(b) for b in missing_branch_arcs[line]]
xline.setAttribute("missing-branches", ",".join(annlines))
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}
}

# -- Options for HTML output ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion lab/goals.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def total_for_files(data, files):
n_branches=sel_summ.get("num_branches", 0),
n_partial_branches=sel_summ.get("num_partial_branches", 0),
n_missing_branches=sel_summ.get("missing_branches", 0),
)
)

return total

Expand Down
2 changes: 1 addition & 1 deletion lab/hack_pyc.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def hack_line_numbers(code):
code.co_argcount, code.co_nlocals, code.co_stacksize, code.co_flags,
code.co_code, tuple(new_consts), code.co_names, code.co_varnames,
code.co_filename, code.co_name, new_firstlineno, new_lnotab
)
)

return new_code

Expand Down
8 changes: 4 additions & 4 deletions lab/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ def main(self, args):
parser.add_option(
"-d", action="store_true", dest="dis",
help="Disassemble"
)
)
parser.add_option(
"-R", action="store_true", dest="recursive",
help="Recurse to find source files"
)
)
parser.add_option(
"-s", action="store_true", dest="source",
help="Show analyzed source"
)
)
parser.add_option(
"-t", action="store_true", dest="tokens",
help="Show tokens"
)
)

options, args = parser.parse_args()
if options.recursive:
Expand Down
2 changes: 1 addition & 1 deletion lab/run_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def trace(frame, event, arg):
os.path.basename(frame.f_code.co_filename),
frame.f_lineno,
frame.f_lasti,
))
))

if event == 'call':
nest += 1
Expand Down
Loading

0 comments on commit 420c013

Please sign in to comment.