summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2023-01-05 20:10:24 -0500
committerNed Batchelder <ned@nedbatchelder.com>2023-01-05 20:10:24 -0500
commit78444f4c06df6a634fa67dd99ee7c07b6b633d9e (patch)
tree4651930bc1ec5449e408c347b2d660522f8ac9e4 /coverage
parentd4339ee90c3146f370d572cbb1b9ab9907daafad (diff)
downloadpython-coveragepy-git-78444f4c06df6a634fa67dd99ee7c07b6b633d9e.tar.gz
style: use good style for annotated defaults parameters
Diffstat (limited to 'coverage')
-rw-r--r--coverage/annotate.py2
-rw-r--r--coverage/cmdline.py12
-rw-r--r--coverage/config.py4
-rw-r--r--coverage/control.py152
-rw-r--r--coverage/data.py14
-rw-r--r--coverage/debug.py26
-rw-r--r--coverage/files.py14
-rw-r--r--coverage/inorout.py4
-rw-r--r--coverage/misc.py8
-rw-r--r--coverage/parser.py30
-rw-r--r--coverage/plugin.py2
-rw-r--r--coverage/plugin_support.py4
-rw-r--r--coverage/python.py4
-rw-r--r--coverage/results.py20
-rw-r--r--coverage/sqldata.py30
-rw-r--r--coverage/summary.py2
-rw-r--r--coverage/types.py4
-rw-r--r--coverage/version.py10
-rw-r--r--coverage/xmlreport.py2
19 files changed, 172 insertions, 172 deletions
diff --git a/coverage/annotate.py b/coverage/annotate.py
index c92c29b7..13dbe9b6 100644
--- a/coverage/annotate.py
+++ b/coverage/annotate.py
@@ -53,7 +53,7 @@ class AnnotateReporter:
blank_re = re.compile(r"\s*(#|$)")
else_re = re.compile(r"\s*else\s*:\s*(#|$)")
- def report(self, morfs: Optional[Iterable[TMorf]], directory: Optional[str]=None) -> None:
+ def report(self, morfs: Optional[Iterable[TMorf]], directory: Optional[str] = None) -> None:
"""Run the report.
See `coverage.report()` for arguments.
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index 18a25fcc..338d8a25 100644
--- a/coverage/cmdline.py
+++ b/coverage/cmdline.py
@@ -321,7 +321,7 @@ class CmdOptionParser(CoverageOptionParser):
action: str,
options: List[optparse.Option],
description: str,
- usage: Optional[str]=None,
+ usage: Optional[str] = None,
):
"""Create an OptionParser for a coverage.py command.
@@ -551,9 +551,9 @@ COMMANDS = {
def show_help(
- error: Optional[str]=None,
- topic: Optional[str]=None,
- parser: Optional[optparse.OptionParser]=None,
+ error: Optional[str] = None,
+ topic: Optional[str] = None,
+ parser: Optional[optparse.OptionParser] = None,
) -> None:
"""Display an error message, or the named topic."""
assert error or topic or parser
@@ -960,7 +960,7 @@ HELP_TOPICS = {
}
-def main(argv: Optional[List[str]]=None) -> Optional[int]:
+def main(argv: Optional[List[str]] = None) -> Optional[int]:
"""The main entry point to coverage.py.
This is installed as the script entry point.
@@ -999,7 +999,7 @@ if _profile: # pragma: debugging
original_main = main
def main( # pylint: disable=function-redefined
- argv: Optional[List[str]]=None,
+ argv: Optional[List[str]] = None,
) -> Optional[int]:
"""A wrapper around main that profiles."""
profiler = SimpleLauncher.launch()
diff --git a/coverage/config.py b/coverage/config.py
index 434a8d2a..ee30b8a4 100644
--- a/coverage/config.py
+++ b/coverage/config.py
@@ -45,7 +45,7 @@ class HandyConfigParser(configparser.ConfigParser):
def read( # type: ignore[override]
self,
filenames: Iterable[str],
- encoding_unused: Optional[str]=None,
+ encoding_unused: Optional[str] = None,
) -> List[str]:
"""Read a file name as UTF-8 configuration data."""
return super().read(filenames, encoding="utf-8")
@@ -430,7 +430,7 @@ class CoverageConfig(TConfigurable):
cp: TConfigParser,
attr: str,
where: str,
- type_: str='',
+ type_: str = '',
) -> bool:
"""Set an attribute on self if it exists in the ConfigParser.
diff --git a/coverage/control.py b/coverage/control.py
index 637a8f6a..d37c77e3 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -114,22 +114,22 @@ class Coverage(TConfigurable):
def __init__( # pylint: disable=too-many-arguments
self,
- data_file: Optional[Union[str, DefaultValue]]=DEFAULT_DATAFILE,
- data_suffix: Optional[Union[str, bool]]=None,
- cover_pylib: Optional[bool]=None,
- auto_data: bool=False,
- timid: Optional[bool]=None,
- branch: Optional[bool]=None,
- config_file: Union[str, bool]=True,
- source: Optional[Iterable[str]]=None,
- source_pkgs: Optional[Iterable[str]]=None,
- omit: Optional[Union[str, Iterable[str]]]=None,
- include: Optional[Union[str, Iterable[str]]]=None,
- debug: Optional[Iterable[str]]=None,
- concurrency: Optional[Union[str, Iterable[str]]]=None,
- check_preimported: bool=False,
- context: Optional[str]=None,
- messages: bool=False,
+ data_file: Optional[Union[str, DefaultValue]] = DEFAULT_DATAFILE,
+ data_suffix: Optional[Union[str, bool]] = None,
+ cover_pylib: Optional[bool] = None,
+ auto_data: bool = False,
+ timid: Optional[bool] = None,
+ branch: Optional[bool] = None,
+ config_file: Union[str, bool] = True,
+ source: Optional[Iterable[str]] = None,
+ source_pkgs: Optional[Iterable[str]] = None,
+ omit: Optional[Union[str, Iterable[str]]] = None,
+ include: Optional[Union[str, Iterable[str]]] = None,
+ debug: Optional[Iterable[str]] = None,
+ concurrency: Optional[Union[str, Iterable[str]]] = None,
+ check_preimported: bool = False,
+ context: Optional[str] = None,
+ messages: bool = False,
) -> None:
"""
Many of these arguments duplicate and override values that can be
@@ -392,7 +392,7 @@ class Coverage(TConfigurable):
return not reason
- def _warn(self, msg: str, slug: Optional[str]=None, once: bool=False) -> None:
+ def _warn(self, msg: str, slug: Optional[str] = None, once: bool = False) -> None:
"""Use `msg` as a warning.
For warning suppression, use `slug` as the shorthand.
@@ -634,7 +634,7 @@ class Coverage(TConfigurable):
self._collector.stop()
self._started = False
- def _atexit(self, event: str="atexit") -> None:
+ def _atexit(self, event: str = "atexit") -> None:
"""Clean up on process shutdown."""
if self._debug.should("process"):
self._debug.write(f"{event}: pid: {os.getpid()}, instance: {self!r}")
@@ -688,13 +688,13 @@ class Coverage(TConfigurable):
self._collector.switch_context(new_context)
- def clear_exclude(self, which: str='exclude') -> None:
+ def clear_exclude(self, which: str = 'exclude') -> None:
"""Clear the exclude list."""
self._init()
setattr(self.config, which + "_list", [])
self._exclude_regex_stale()
- def exclude(self, regex: str, which: str='exclude') -> None:
+ def exclude(self, regex: str, which: str = 'exclude') -> None:
"""Exclude source lines from execution consideration.
A number of lists of regular expressions are maintained. Each list
@@ -726,7 +726,7 @@ class Coverage(TConfigurable):
self._exclude_re[which] = join_regex(excl_list)
return self._exclude_re[which]
- def get_exclude_list(self, which: str='exclude') -> List[str]:
+ def get_exclude_list(self, which: str = 'exclude') -> List[str]:
"""Return a list of excluded regex strings.
`which` indicates which list is desired. See :meth:`exclude` for the
@@ -755,9 +755,9 @@ class Coverage(TConfigurable):
def combine(
self,
- data_paths: Optional[Iterable[str]]=None,
- strict: bool=False,
- keep: bool=False
+ data_paths: Optional[Iterable[str]] = None,
+ strict: bool = False,
+ keep: bool = False
) -> None:
"""Combine together a number of similarly-named coverage data files.
@@ -926,7 +926,7 @@ class Coverage(TConfigurable):
assert isinstance(file_reporter, FileReporter)
return file_reporter
- def _get_file_reporters(self, morfs: Optional[Iterable[TMorf]]=None) -> List[FileReporter]:
+ def _get_file_reporters(self, morfs: Optional[Iterable[TMorf]] = None) -> List[FileReporter]:
"""Get a list of FileReporters for a list of modules or file names.
For each module or file name in `morfs`, find a FileReporter. Return
@@ -956,18 +956,18 @@ class Coverage(TConfigurable):
def report(
self,
- morfs: Optional[Iterable[TMorf]]=None,
- show_missing: Optional[bool]=None,
- ignore_errors: Optional[bool]=None,
- file: Optional[IO[str]]=None,
- omit: Optional[Union[str, List[str]]]=None,
- include: Optional[Union[str, List[str]]]=None,
- skip_covered: Optional[bool]=None,
- contexts: Optional[List[str]]=None,
- skip_empty: Optional[bool]=None,
- precision: Optional[int]=None,
- sort: Optional[str]=None,
- output_format: Optional[str]=None,
+ morfs: Optional[Iterable[TMorf]] = None,
+ show_missing: Optional[bool] = None,
+ ignore_errors: Optional[bool] = None,
+ file: Optional[IO[str]] = None,
+ omit: Optional[Union[str, List[str]]] = None,
+ include: Optional[Union[str, List[str]]] = None,
+ skip_covered: Optional[bool] = None,
+ contexts: Optional[List[str]] = None,
+ skip_empty: Optional[bool] = None,
+ precision: Optional[int] = None,
+ sort: Optional[str] = None,
+ output_format: Optional[str] = None,
) -> float:
"""Write a textual summary report to `file`.
@@ -1038,12 +1038,12 @@ class Coverage(TConfigurable):
def annotate(
self,
- morfs: Optional[Iterable[TMorf]]=None,
- directory: Optional[str]=None,
- ignore_errors: Optional[bool]=None,
- omit: Optional[Union[str, List[str]]]=None,
- include: Optional[Union[str, List[str]]]=None,
- contexts: Optional[List[str]]=None,
+ morfs: Optional[Iterable[TMorf]] = None,
+ directory: Optional[str] = None,
+ ignore_errors: Optional[bool] = None,
+ omit: Optional[Union[str, List[str]]] = None,
+ include: Optional[Union[str, List[str]]] = None,
+ contexts: Optional[List[str]] = None,
) -> None:
"""Annotate a list of modules.
@@ -1077,18 +1077,18 @@ class Coverage(TConfigurable):
def html_report(
self,
- morfs: Optional[Iterable[TMorf]]=None,
- directory: Optional[str]=None,
- ignore_errors: Optional[bool]=None,
- omit: Optional[Union[str, List[str]]]=None,
- include: Optional[Union[str, List[str]]]=None,
- extra_css: Optional[str]=None,
- title: Optional[str]=None,
- skip_covered: Optional[bool]=None,
- show_contexts: Optional[bool]=None,
- contexts: Optional[List[str]]=None,
- skip_empty: Optional[bool]=None,
- precision: Optional[int]=None,
+ morfs: Optional[Iterable[TMorf]] = None,
+ directory: Optional[str] = None,
+ ignore_errors: Optional[bool] = None,
+ omit: Optional[Union[str, List[str]]] = None,
+ include: Optional[Union[str, List[str]]] = None,
+ extra_css: Optional[str] = None,
+ title: Optional[str] = None,
+ skip_covered: Optional[bool] = None,
+ show_contexts: Optional[bool] = None,
+ contexts: Optional[List[str]] = None,
+ skip_empty: Optional[bool] = None,
+ precision: Optional[int] = None,
) -> float:
"""Generate an HTML report.
@@ -1135,13 +1135,13 @@ class Coverage(TConfigurable):
def xml_report(
self,
- morfs: Optional[Iterable[TMorf]]=None,
- outfile: Optional[str]=None,
- ignore_errors: Optional[bool]=None,
- omit: Optional[Union[str, List[str]]]=None,
- include: Optional[Union[str, List[str]]]=None,
- contexts: Optional[List[str]]=None,
- skip_empty: Optional[bool]=None,
+ morfs: Optional[Iterable[TMorf]] = None,
+ outfile: Optional[str] = None,
+ ignore_errors: Optional[bool] = None,
+ omit: Optional[Union[str, List[str]]] = None,
+ include: Optional[Union[str, List[str]]] = None,
+ contexts: Optional[List[str]] = None,
+ skip_empty: Optional[bool] = None,
) -> float:
"""Generate an XML report of coverage results.
@@ -1169,14 +1169,14 @@ class Coverage(TConfigurable):
def json_report(
self,
- morfs: Optional[Iterable[TMorf]]=None,
- outfile: Optional[str]=None,
- ignore_errors: Optional[bool]=None,
- omit: Optional[Union[str, List[str]]]=None,
- include: Optional[Union[str, List[str]]]=None,
- contexts: Optional[List[str]]=None,
- pretty_print: Optional[bool]=None,
- show_contexts: Optional[bool]=None,
+ morfs: Optional[Iterable[TMorf]] = None,
+ outfile: Optional[str] = None,
+ ignore_errors: Optional[bool] = None,
+ omit: Optional[Union[str, List[str]]] = None,
+ include: Optional[Union[str, List[str]]] = None,
+ contexts: Optional[List[str]] = None,
+ pretty_print: Optional[bool] = None,
+ show_contexts: Optional[bool] = None,
) -> float:
"""Generate a JSON report of coverage results.
@@ -1207,12 +1207,12 @@ class Coverage(TConfigurable):
def lcov_report(
self,
- morfs: Optional[Iterable[TMorf]]=None,
- outfile: Optional[str]=None,
- ignore_errors: Optional[bool]=None,
- omit: Optional[Union[str, List[str]]]=None,
- include: Optional[Union[str, List[str]]]=None,
- contexts: Optional[List[str]]=None,
+ morfs: Optional[Iterable[TMorf]] = None,
+ outfile: Optional[str] = None,
+ ignore_errors: Optional[bool] = None,
+ omit: Optional[Union[str, List[str]]] = None,
+ include: Optional[Union[str, List[str]]] = None,
+ contexts: Optional[List[str]] = None,
) -> float:
"""Generate an LCOV report of coverage results.
diff --git a/coverage/data.py b/coverage/data.py
index 8e987a33..ee4f007d 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -24,7 +24,7 @@ from coverage.misc import Hasher, file_be_gone, human_sorted, plural
from coverage.sqldata import CoverageData
-def line_counts(data: CoverageData, fullpath: bool=False) -> Dict[str, int]:
+def line_counts(data: CoverageData, fullpath: bool = False) -> Dict[str, int]:
"""Return a dict summarizing the line coverage data.
Keys are based on the file names, and values are the number of executed
@@ -62,7 +62,7 @@ def add_data_to_hash(data: CoverageData, filename: str, hasher: Hasher) -> None:
hasher.update(data.file_tracer(filename))
-def combinable_files(data_file: str, data_paths: Optional[Iterable[str]]=None) -> List[str]:
+def combinable_files(data_file: str, data_paths: Optional[Iterable[str]] = None) -> List[str]:
"""Make a list of data files to be combined.
`data_file` is a path to a data file. `data_paths` is a list of files or
@@ -87,11 +87,11 @@ def combinable_files(data_file: str, data_paths: Optional[Iterable[str]]=None) -
def combine_parallel_data(
data: CoverageData,
- aliases: Optional[PathAliases]=None,
- data_paths: Optional[Iterable[str]]=None,
- strict: bool=False,
- keep: bool=False,
- message: Optional[Callable[[str], None]]=None,
+ aliases: Optional[PathAliases] = None,
+ data_paths: Optional[Iterable[str]] = None,
+ strict: bool = False,
+ keep: bool = False,
+ message: Optional[Callable[[str], None]] = None,
) -> None:
"""Combine a number of data files together.
diff --git a/coverage/debug.py b/coverage/debug.py
index 145802b1..c4cc229a 100644
--- a/coverage/debug.py
+++ b/coverage/debug.py
@@ -160,7 +160,7 @@ def write_formatted_info(
write(f" {line}")
-def short_stack(limit: Optional[int]=None, skip: int=0) -> str:
+def short_stack(limit: Optional[int] = None, skip: int = 0) -> str:
"""Return a string summarizing the call stack.
The string is multi-line, with one line per stack frame. Each line shows
@@ -183,9 +183,9 @@ def short_stack(limit: Optional[int]=None, skip: int=0) -> str:
def dump_stack_frames(
- limit: Optional[int]=None,
- out: Optional[TWritable]=None,
- skip: int=0
+ limit: Optional[int] = None,
+ out: Optional[TWritable] = None,
+ skip: int = 0
) -> None:
"""Print a summary of the stack to stdout, or someplace else."""
out = out or sys.stdout
@@ -193,7 +193,7 @@ def dump_stack_frames(
out.write("\n")
-def clipped_repr(text: str, numchars: int=50) -> str:
+def clipped_repr(text: str, numchars: int = 50) -> str:
"""`repr(text)`, but limited to `numchars`."""
r = reprlib.Repr()
r.maxstring = numchars
@@ -312,10 +312,10 @@ class DebugOutputFile: # pragma: debugging
@classmethod
def get_one(
cls,
- fileobj: Optional[IO[str]]=None,
- show_process: bool=True,
- filters: Iterable[Callable[[str], str]]=(),
- interim: bool=False,
+ fileobj: Optional[IO[str]] = None,
+ show_process: bool = True,
+ filters: Iterable[Callable[[str], str]] = (),
+ interim: bool = False,
) -> DebugOutputFile:
"""Get a DebugOutputFile.
@@ -371,7 +371,7 @@ class DebugOutputFile: # pragma: debugging
self.outfile.flush()
-def log(msg: str, stack: bool=False) -> None: # pragma: debugging
+def log(msg: str, stack: bool = False) -> None: # pragma: debugging
"""Write a log message as forcefully as possible."""
out = DebugOutputFile.get_one(interim=True)
out.write(msg+"\n")
@@ -411,9 +411,9 @@ CALLS = itertools.count()
OBJ_ID_ATTR = "$coverage.object_id"
def show_calls(
- show_args: bool=True,
- show_stack: bool=False,
- show_return: bool=False,
+ show_args: bool = True,
+ show_stack: bool = False,
+ show_return: bool = False,
) -> Callable[..., Any]: # pragma: debugging
"""A method decorator to debug-log each call to the function."""
def _decorator(func):
diff --git a/coverage/files.py b/coverage/files.py
index e2800bf2..962a9d10 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -224,7 +224,7 @@ class TreeMatcher:
somewhere in a subtree rooted at one of the directories.
"""
- def __init__(self, paths: Iterable[str], name: str="unknown") -> None:
+ def __init__(self, paths: Iterable[str], name: str = "unknown") -> None:
self.original_paths: List[str] = human_sorted(paths)
#self.paths = list(map(os.path.normcase, paths))
self.paths = [os.path.normcase(p) for p in paths]
@@ -282,7 +282,7 @@ class ModuleMatcher:
class GlobMatcher:
"""A matcher for files by file name pattern."""
- def __init__(self, pats: Iterable[str], name: str="unknown") -> None:
+ def __init__(self, pats: Iterable[str], name: str = "unknown") -> None:
self.pats = list(pats)
self.re = globs_to_regex(self.pats, case_insensitive=env.WINDOWS)
self.name = name
@@ -350,8 +350,8 @@ def _glob_to_regex(pattern: str) -> str:
def globs_to_regex(
patterns: Iterable[str],
- case_insensitive: bool=False,
- partial: bool=False,
+ case_insensitive: bool = False,
+ partial: bool = False,
) -> re.Pattern[str]:
"""Convert glob patterns to a compiled regex that matches any of them.
@@ -392,8 +392,8 @@ class PathAliases:
"""
def __init__(
self,
- debugfn: Optional[Callable[[str], None]]=None,
- relative: bool=False,
+ debugfn: Optional[Callable[[str], None]] = None,
+ relative: bool = False,
) -> None:
# A list of (original_pattern, regex, result)
self.aliases: List[Tuple[str, re.Pattern[str], str]] = []
@@ -446,7 +446,7 @@ class PathAliases:
result = result.rstrip(r"\/") + result_sep
self.aliases.append((original_pattern, regex, result))
- def map(self, path: str, exists:Callable[[str], bool]=source_exists) -> str:
+ def map(self, path: str, exists:Callable[[str], bool] = source_exists) -> str:
"""Map `path` through the aliases.
`path` is checked against all of the patterns. The first pattern to
diff --git a/coverage/inorout.py b/coverage/inorout.py
index c43e43a4..d5ca938f 100644
--- a/coverage/inorout.py
+++ b/coverage/inorout.py
@@ -56,7 +56,7 @@ if env.PYPY:
pass
-def canonical_path(morf: TMorf, directory: bool=False) -> str:
+def canonical_path(morf: TMorf, directory: bool = False) -> str:
"""Return the canonical path of the module or file `morf`.
If the module is a package, then return its directory. If it is a
@@ -294,7 +294,7 @@ class InOrOut:
self.plugins: Plugins
self.disp_class: Type[TFileDisposition] = FileDisposition
- def should_trace(self, filename: str, frame: Optional[FrameType]=None) -> TFileDisposition:
+ def should_trace(self, filename: str, frame: Optional[FrameType] = None) -> TFileDisposition:
"""Decide whether to trace execution in `filename`, with a reason.
This function is called from the trace function. As each new file name
diff --git a/coverage/misc.py b/coverage/misc.py
index c2041b47..e0658eb1 100644
--- a/coverage/misc.py
+++ b/coverage/misc.py
@@ -180,7 +180,7 @@ def ensure_dir_for_file(path: str) -> None:
ensure_dir(os.path.dirname(path))
-def output_encoding(outfile: Optional[IO[str]]=None) -> str:
+def output_encoding(outfile: Optional[IO[str]] = None) -> str:
"""Determine the encoding to use for output written to `outfile` or stdout."""
if outfile is None:
outfile = sys.stdout
@@ -318,7 +318,7 @@ def format_local_datetime(dt: datetime.datetime) -> str:
return dt.astimezone().strftime('%Y-%m-%d %H:%M %z')
-def import_local_file(modname: str, modfile: Optional[str]=None) -> ModuleType:
+def import_local_file(modname: str, modfile: Optional[str] = None) -> ModuleType:
"""Import a local file as a module.
Opens a file in the current directory named `modname`.py, imports it
@@ -365,7 +365,7 @@ SortableItem = TypeVar("SortableItem", bound=Sequence[Any])
def human_sorted_items(
items: Iterable[SortableItem],
- reverse: bool=False,
+ reverse: bool = False,
) -> List[SortableItem]:
"""Sort (string, ...) items the way humans expect.
@@ -377,7 +377,7 @@ def human_sorted_items(
return sorted(items, key=lambda item: (_human_key(item[0]), *item[1:]), reverse=reverse)
-def plural(n: int, thing: str="", things: str="") -> str:
+def plural(n: int, thing: str = "", things: str = "") -> str:
"""Pluralize a word.
If n is 1, return thing. Otherwise return things, or thing+s.
diff --git a/coverage/parser.py b/coverage/parser.py
index cb4e6474..37d74767 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -36,9 +36,9 @@ class PythonParser:
"""
def __init__(
self,
- text: Optional[str]=None,
- filename: Optional[str]=None,
- exclude: Optional[str]=None,
+ text: Optional[str] = None,
+ filename: Optional[str] = None,
+ exclude: Optional[str] = None,
) -> None:
"""
Source can be provided as `text`, the text itself, or `filename`, from
@@ -328,7 +328,7 @@ class PythonParser:
self,
start: TLineNo,
end: TLineNo,
- executed_arcs: Optional[Iterable[TArc]]=None,
+ executed_arcs: Optional[Iterable[TArc]] = None,
) -> str:
"""Provide an English sentence describing a missing arc."""
if self._missing_arc_fragments is None:
@@ -376,8 +376,8 @@ class ByteParser:
def __init__(
self,
text: str,
- code: Optional[CodeType]=None,
- filename: Optional[str]=None,
+ code: Optional[CodeType] = None,
+ filename: Optional[str] = None,
) -> None:
self.text = text
if code is not None:
@@ -459,7 +459,7 @@ class ArcStart(collections.namedtuple("Arc", "lineno, cause")):
to have `lineno` interpolated into it.
"""
- def __new__(cls, lineno: TLineNo, cause: Optional[str]=None) -> ArcStart:
+ def __new__(cls, lineno: TLineNo, cause: Optional[str] = None) -> ArcStart:
return super().__new__(cls, lineno, cause)
@@ -469,8 +469,8 @@ class TAddArcFn(Protocol):
self,
start: TLineNo,
end: TLineNo,
- smsg: Optional[str]=None,
- emsg: Optional[str]=None,
+ smsg: Optional[str] = None,
+ emsg: Optional[str] = None,
) -> None:
...
@@ -613,7 +613,7 @@ class WithBlock(Block):
self,
exits: Set[ArcStart],
add_arc: TAddArcFn,
- from_set: Optional[Set[ArcStart]]=None,
+ from_set: Optional[Set[ArcStart]] = None,
) -> bool:
"""Helper to process the four kinds of exits."""
for xit in exits:
@@ -713,8 +713,8 @@ class AstArcAnalyzer:
self,
start: TLineNo,
end: TLineNo,
- smsg: Optional[str]=None,
- emsg: Optional[str]=None,
+ smsg: Optional[str] = None,
+ emsg: Optional[str] = None,
) -> None:
"""Add an arc, including message fragments to use if it is missing."""
if self.debug: # pragma: debugging
@@ -829,8 +829,8 @@ class AstArcAnalyzer:
def add_body_arcs(
self,
body: Sequence[ast.AST],
- from_start: Optional[ArcStart]=None,
- prev_starts: Optional[Set[ArcStart]]=None
+ from_start: Optional[ArcStart] = None,
+ prev_starts: Optional[Set[ArcStart]] = None
) -> Set[ArcStart]:
"""Add arcs for the body of a compound statement.
@@ -1362,7 +1362,7 @@ def _is_simple_value(value: Any) -> bool:
def ast_dump(
node: ast.AST,
depth: int = 0,
- print: Callable[[str], None]=print, # pylint: disable=redefined-builtin
+ print: Callable[[str], None] = print, # pylint: disable=redefined-builtin
) -> None:
"""Dump the AST for `node`.
diff --git a/coverage/plugin.py b/coverage/plugin.py
index da91aac4..5279c4d0 100644
--- a/coverage/plugin.py
+++ b/coverage/plugin.py
@@ -496,7 +496,7 @@ class FileReporter(CoveragePluginBase):
self,
start: TLineNo,
end: TLineNo,
- executed_arcs: Optional[Iterable[TArc]]=None, # pylint: disable=unused-argument
+ executed_arcs: Optional[Iterable[TArc]] = None, # pylint: disable=unused-argument
) -> str:
"""Provide an English sentence describing a missing arc.
diff --git a/coverage/plugin_support.py b/coverage/plugin_support.py
index 8ac42491..62985a06 100644
--- a/coverage/plugin_support.py
+++ b/coverage/plugin_support.py
@@ -39,7 +39,7 @@ class Plugins:
cls,
modules: Iterable[str],
config: CoverageConfig,
- debug: Optional[TDebugCtl]=None,
+ debug: Optional[TDebugCtl] = None,
) -> Plugins:
"""Load plugins from `modules`.
@@ -139,7 +139,7 @@ class Plugins:
class LabelledDebug:
"""A Debug writer, but with labels for prepending to the messages."""
- def __init__(self, label: str, debug: TDebugCtl, prev_labels: Iterable[str]=()):
+ def __init__(self, label: str, debug: TDebugCtl, prev_labels: Iterable[str] = ()):
self.labels = list(prev_labels) + [label]
self.debug = debug
diff --git a/coverage/python.py b/coverage/python.py
index c25a03fd..98b0d6ab 100644
--- a/coverage/python.py
+++ b/coverage/python.py
@@ -144,7 +144,7 @@ def source_for_morf(morf: TMorf) -> str:
class PythonFileReporter(FileReporter):
"""Report support for a Python file."""
- def __init__(self, morf: TMorf, coverage: Optional[Coverage]=None) -> None:
+ def __init__(self, morf: TMorf, coverage: Optional[Coverage] = None) -> None:
self.coverage = coverage
filename = source_for_morf(morf)
@@ -224,7 +224,7 @@ class PythonFileReporter(FileReporter):
self,
start: TLineNo,
end: TLineNo,
- executed_arcs: Optional[Iterable[TArc]]=None,
+ executed_arcs: Optional[Iterable[TArc]] = None,
) -> str:
return self.parser.missing_arc_description(start, end, executed_arcs)
diff --git a/coverage/results.py b/coverage/results.py
index 4990d435..2731700e 100644
--- a/coverage/results.py
+++ b/coverage/results.py
@@ -67,7 +67,7 @@ class Analysis:
n_missing_branches=n_missing_branches,
)
- def missing_formatted(self, branches: bool=False) -> str:
+ def missing_formatted(self, branches: bool = False) -> str:
"""The missing line numbers, formatted nicely.
Returns a string like "1-2, 5-11, 13-14".
@@ -188,14 +188,14 @@ class Numbers(AutoReprMixin):
def __init__(
self,
- precision: int=0,
- n_files: int=0,
- n_statements: int=0,
- n_excluded: int=0,
- n_missing: int=0,
- n_branches: int=0,
- n_partial_branches: int=0,
- n_missing_branches: int=0,
+ precision: int = 0,
+ n_files: int = 0,
+ n_statements: int = 0,
+ n_excluded: int = 0,
+ n_missing: int = 0,
+ n_branches: int = 0,
+ n_partial_branches: int = 0,
+ n_missing_branches: int = 0,
) -> None:
assert 0 <= precision < 10
self._precision = precision
@@ -329,7 +329,7 @@ def _line_ranges(
def format_lines(
statements: Iterable[TLineNo],
lines: Iterable[TLineNo],
- arcs: Optional[Iterable[Tuple[TLineNo, List[TLineNo]]]]=None,
+ arcs: Optional[Iterable[Tuple[TLineNo, List[TLineNo]]]] = None,
) -> str:
"""Nicely format a list of line numbers.
diff --git a/coverage/sqldata.py b/coverage/sqldata.py
index 0a2f87a5..da66ad09 100644
--- a/coverage/sqldata.py
+++ b/coverage/sqldata.py
@@ -212,11 +212,11 @@ class CoverageData(AutoReprMixin):
def __init__(
self,
- basename: Optional[str]=None,
- suffix: Optional[Union[str, bool]]=None,
- no_disk: bool=False,
- warn: Optional[TWarnFn]=None,
- debug: Optional[TDebugCtl]=None,
+ basename: Optional[str] = None,
+ suffix: Optional[Union[str, bool]] = None,
+ no_disk: bool = False,
+ warn: Optional[TWarnFn] = None,
+ debug: Optional[TDebugCtl] = None,
) -> None:
"""Create a :class:`CoverageData` object to hold coverage-measured data.
@@ -403,7 +403,7 @@ class CoverageData(AutoReprMixin):
self._read_db()
self._have_used = True
- def _file_id(self, filename: str, add: bool=False) -> Optional[int]:
+ def _file_id(self, filename: str, add: bool = False) -> Optional[int]:
"""Get the file id for `filename`.
If filename is not in the database yet, add it if `add` is True.
@@ -536,7 +536,7 @@ class CoverageData(AutoReprMixin):
data,
)
- def _choose_lines_or_arcs(self, lines: bool=False, arcs: bool=False) -> None:
+ def _choose_lines_or_arcs(self, lines: bool = False, arcs: bool = False) -> None:
"""Force the data file to choose between lines and arcs."""
assert lines or arcs
assert not (lines and arcs)
@@ -591,7 +591,7 @@ class CoverageData(AutoReprMixin):
(file_id, plugin_name)
)
- def touch_file(self, filename: str, plugin_name: str="") -> None:
+ def touch_file(self, filename: str, plugin_name: str = "") -> None:
"""Ensure that `filename` appears in the data, empty if needed.
`plugin_name` is the name of the plugin responsible for this file.
@@ -599,7 +599,7 @@ class CoverageData(AutoReprMixin):
"""
self.touch_files([filename], plugin_name)
- def touch_files(self, filenames: Iterable[str], plugin_name: Optional[str]=None) -> None:
+ def touch_files(self, filenames: Iterable[str], plugin_name: Optional[str] = None) -> None:
"""Ensure that `filenames` appear in the data, empty if needed.
`plugin_name` is the name of the plugin responsible for these files.
@@ -618,7 +618,7 @@ class CoverageData(AutoReprMixin):
# Set the tracer for this file
self.add_file_tracers({filename: plugin_name})
- def update(self, other_data: CoverageData, aliases: Optional[PathAliases]=None) -> None:
+ def update(self, other_data: CoverageData, aliases: Optional[PathAliases] = None) -> None:
"""Update this data with data from several other :class:`CoverageData` instances.
If `aliases` is provided, it's a `PathAliases` object that is used to
@@ -787,7 +787,7 @@ class CoverageData(AutoReprMixin):
self._reset()
self.read()
- def erase(self, parallel: bool=False) -> None:
+ def erase(self, parallel: bool = False) -> None:
"""Erase the data in this object.
If `parallel` is true, then also deletes data files created from the
@@ -1170,7 +1170,7 @@ class SqliteDb(AutoReprMixin):
def execute(
self,
sql: str,
- parameters: Iterable[Any]=(),
+ parameters: Iterable[Any] = (),
) -> Iterator[sqlite3.Cursor]:
"""Context managed :meth:`python:sqlite3.Connection.execute`.
@@ -1182,11 +1182,11 @@ class SqliteDb(AutoReprMixin):
finally:
cur.close()
- def execute_void(self, sql: str, parameters: Iterable[Any]=()) -> None:
+ def execute_void(self, sql: str, parameters: Iterable[Any] = ()) -> None:
"""Same as :meth:`python:sqlite3.Connection.execute` when you don't need the cursor."""
self._execute(sql, parameters).close()
- def execute_for_rowid(self, sql: str, parameters: Iterable[Any]=()) -> int:
+ def execute_for_rowid(self, sql: str, parameters: Iterable[Any] = ()) -> int:
"""Like execute, but returns the lastrowid."""
with self.execute(sql, parameters) as cur:
assert cur.lastrowid is not None
@@ -1195,7 +1195,7 @@ class SqliteDb(AutoReprMixin):
self.debug.write(f"Row id result: {rowid!r}")
return rowid
- def execute_one(self, sql: str, parameters: Iterable[Any]=()) -> Optional[Tuple[Any, ...]]:
+ def execute_one(self, sql: str, parameters: Iterable[Any] = ()) -> Optional[Tuple[Any, ...]]:
"""Execute a statement and return the one row that results.
This is like execute(sql, parameters).fetchone(), except it is
diff --git a/coverage/summary.py b/coverage/summary.py
index 287e7593..c4c7fd1d 100644
--- a/coverage/summary.py
+++ b/coverage/summary.py
@@ -169,7 +169,7 @@ class SummaryReporter:
for end_line in end_lines:
self.write(end_line)
- def report(self, morfs: Optional[Iterable[TMorf]], outfile: Optional[IO[str]]=None) -> float:
+ def report(self, morfs: Optional[Iterable[TMorf]], outfile: Optional[IO[str]] = None) -> float:
"""Writes a report summarizing coverage statistics per module.
`outfile` is a text-mode file object to write the summary to.
diff --git a/coverage/types.py b/coverage/types.py
index 8ec4f37a..a45b831e 100644
--- a/coverage/types.py
+++ b/coverage/types.py
@@ -32,7 +32,7 @@ class TTraceFn(Protocol):
frame: FrameType,
event: str,
arg: Any,
- lineno: Optional[int]=None # Our own twist, see collector.py
+ lineno: Optional[int] = None # Our own twist, see collector.py
) -> TTraceFn:
...
@@ -156,7 +156,7 @@ class TPlugin(Protocol):
class TWarnFn(Protocol):
"""A callable warn() function."""
- def __call__(self, msg: str, slug: Optional[str]=None, once: bool=False,) -> None:
+ def __call__(self, msg: str, slug: Optional[str] = None, once: bool = False,) -> None:
...
diff --git a/coverage/version.py b/coverage/version.py
index bee051d5..a1f3cda0 100644
--- a/coverage/version.py
+++ b/coverage/version.py
@@ -16,9 +16,9 @@ def _make_version(
major: int,
minor: int,
micro: int,
- releaselevel: str="final",
- serial: int=0,
- dev: int=0,
+ releaselevel: str = "final",
+ serial: int = 0,
+ dev: int = 0,
) -> str:
"""Create a readable version string from version_info tuple components."""
assert releaselevel in ['alpha', 'beta', 'candidate', 'final']
@@ -36,8 +36,8 @@ def _make_url(
minor: int,
micro: int,
releaselevel: str,
- serial: int=0,
- dev: int=0,
+ serial: int = 0,
+ dev: int = 0,
) -> str:
"""Make the URL people should start at for this version of coverage.py."""
url = "https://coverage.readthedocs.io"
diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py
index 19a8dba5..86fdc18f 100644
--- a/coverage/xmlreport.py
+++ b/coverage/xmlreport.py
@@ -67,7 +67,7 @@ class XmlReporter:
self.packages: Dict[str, PackageData] = {}
self.xml_out: xml.dom.minidom.Document
- def report(self, morfs: Optional[Iterable[TMorf]], outfile: Optional[IO[str]]=None) -> float:
+ def report(self, morfs: Optional[Iterable[TMorf]], outfile: Optional[IO[str]] = None) -> float:
"""Generate a Cobertura-compatible XML report for `morfs`.
`morfs` is a list of modules or file names.