diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-05 20:10:24 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-05 20:10:24 -0500 |
commit | 78444f4c06df6a634fa67dd99ee7c07b6b633d9e (patch) | |
tree | 4651930bc1ec5449e408c347b2d660522f8ac9e4 | |
parent | d4339ee90c3146f370d572cbb1b9ab9907daafad (diff) | |
download | python-coveragepy-git-78444f4c06df6a634fa67dd99ee7c07b6b633d9e.tar.gz |
style: use good style for annotated defaults parameters
-rw-r--r-- | coverage/annotate.py | 2 | ||||
-rw-r--r-- | coverage/cmdline.py | 12 | ||||
-rw-r--r-- | coverage/config.py | 4 | ||||
-rw-r--r-- | coverage/control.py | 152 | ||||
-rw-r--r-- | coverage/data.py | 14 | ||||
-rw-r--r-- | coverage/debug.py | 26 | ||||
-rw-r--r-- | coverage/files.py | 14 | ||||
-rw-r--r-- | coverage/inorout.py | 4 | ||||
-rw-r--r-- | coverage/misc.py | 8 | ||||
-rw-r--r-- | coverage/parser.py | 30 | ||||
-rw-r--r-- | coverage/plugin.py | 2 | ||||
-rw-r--r-- | coverage/plugin_support.py | 4 | ||||
-rw-r--r-- | coverage/python.py | 4 | ||||
-rw-r--r-- | coverage/results.py | 20 | ||||
-rw-r--r-- | coverage/sqldata.py | 30 | ||||
-rw-r--r-- | coverage/summary.py | 2 | ||||
-rw-r--r-- | coverage/types.py | 4 | ||||
-rw-r--r-- | coverage/version.py | 10 | ||||
-rw-r--r-- | coverage/xmlreport.py | 2 | ||||
-rw-r--r-- | lab/benchmark.py | 2 | ||||
-rw-r--r-- | tests/coveragetest.py | 48 | ||||
-rw-r--r-- | tests/goldtest.py | 6 | ||||
-rw-r--r-- | tests/helpers.py | 14 | ||||
-rw-r--r-- | tests/mixins.py | 6 | ||||
-rw-r--r-- | tests/test_api.py | 4 | ||||
-rw-r--r-- | tests/test_cmdline.py | 20 | ||||
-rw-r--r-- | tests/test_concurrency.py | 6 | ||||
-rw-r--r-- | tests/test_data.py | 2 | ||||
-rw-r--r-- | tests/test_files.py | 10 | ||||
-rw-r--r-- | tests/test_html.py | 12 | ||||
-rw-r--r-- | tests/test_lcov.py | 2 | ||||
-rw-r--r-- | tests/test_xml.py | 4 |
32 files changed, 240 insertions, 240 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. diff --git a/lab/benchmark.py b/lab/benchmark.py index f3bc86d7..4c5de3c4 100644 --- a/lab/benchmark.py +++ b/lab/benchmark.py @@ -157,7 +157,7 @@ class ProjectToTest: class EmptyProject(ProjectToTest): """A dummy project for testing other parts of this code.""" - def __init__(self, slug: str="empty", fake_durations: Iterable[float]=(1.23,)): + def __init__(self, slug: str = "empty", fake_durations: Iterable[float] = (1.23,)): self.slug = slug self.durations = iter(itertools.cycle(fake_durations)) diff --git a/tests/coveragetest.py b/tests/coveragetest.py index 100b8e3b..0055c691 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -76,7 +76,7 @@ class CoverageTest( self, cov: Coverage, modname: str, - modfile: Optional[str]=None + modfile: Optional[str] = None ) -> ModuleType: """Start coverage, import a file, then stop coverage. @@ -96,7 +96,7 @@ class CoverageTest( cov.stop() return mod - def get_report(self, cov: Coverage, squeeze: bool=True, **kwargs: Any) -> str: + def get_report(self, cov: Coverage, squeeze: bool = True, **kwargs: Any) -> str: """Get the report from `cov`, and canonicalize it.""" repout = io.StringIO() kwargs.setdefault("show_missing", False) @@ -137,17 +137,17 @@ class CoverageTest( def check_coverage( self, text: str, - lines: Optional[Union[Sequence[TLineNo], Sequence[List[TLineNo]]]]=None, - missing: Union[str, Sequence[str]]="", - report: str="", - excludes: Optional[Iterable[str]]=None, - partials: Iterable[str]=(), - arcz: Optional[str]=None, - arcz_missing: Optional[str]=None, - arcz_unpredicted: Optional[str]=None, - arcs: Optional[Iterable[TArc]]=None, - arcs_missing: Optional[Iterable[TArc]]=None, - arcs_unpredicted: Optional[Iterable[TArc]]=None, + lines: Optional[Union[Sequence[TLineNo], Sequence[List[TLineNo]]]] = None, + missing: Union[str, Sequence[str]] = "", + report: str = "", + excludes: Optional[Iterable[str]] = None, + partials: Iterable[str] = (), + arcz: Optional[str] = None, + arcz_missing: Optional[str] = None, + arcz_unpredicted: Optional[str] = None, + arcs: Optional[Iterable[TArc]] = None, + arcs_missing: Optional[Iterable[TArc]] = None, + arcs_unpredicted: Optional[Iterable[TArc]] = None, ) -> Coverage: """Check the coverage measurement of `text`. @@ -248,11 +248,11 @@ class CoverageTest( def make_data_file( self, - basename: Optional[str]=None, - suffix: Optional[str]=None, - lines: Optional[Mapping[str, Collection[TLineNo]]]=None, - arcs: Optional[Mapping[str, Collection[TArc]]]=None, - file_tracers: Optional[Mapping[str, str]]=None, + basename: Optional[str] = None, + suffix: Optional[str] = None, + lines: Optional[Mapping[str, Collection[TLineNo]]] = None, + arcs: Optional[Mapping[str, Collection[TArc]]] = None, + file_tracers: Optional[Mapping[str, str]] = None, ) -> CoverageData: """Write some data into a coverage data file.""" data = coverage.CoverageData(basename=basename, suffix=suffix) @@ -271,7 +271,7 @@ class CoverageTest( self, cov: Coverage, warnings: Iterable[str], - not_warnings: Iterable[str]=(), + not_warnings: Iterable[str] = (), ) -> Iterator[None]: """A context manager to check that particular warnings happened in `cov`. @@ -292,8 +292,8 @@ class CoverageTest( saved_warnings = [] def capture_warning( msg: str, - slug: Optional[str]=None, - once: bool=False, # pylint: disable=unused-argument + slug: Optional[str] = None, + once: bool = False, # pylint: disable=unused-argument ) -> None: """A fake implementation of Coverage._warn, to capture warnings.""" # NOTE: we don't implement `once`. @@ -353,15 +353,15 @@ class CoverageTest( def assert_recent_datetime( self, dt: datetime.datetime, - seconds: int=10, - msg: Optional[str]=None, + seconds: int = 10, + msg: Optional[str] = None, ) -> None: """Assert that `dt` marks a time at most `seconds` seconds ago.""" age = datetime.datetime.now() - dt assert age.total_seconds() >= 0, msg assert age.total_seconds() <= seconds, msg - def command_line(self, args: str, ret: int=OK) -> None: + def command_line(self, args: str, ret: int = OK) -> None: """Run `args` through the command line. Use this when you want to run the full coverage machinery, but in the diff --git a/tests/goldtest.py b/tests/goldtest.py index 4d2be842..12a04af6 100644 --- a/tests/goldtest.py +++ b/tests/goldtest.py @@ -27,9 +27,9 @@ def gold_path(path: str) -> str: def compare( expected_dir: str, actual_dir: str, - file_pattern: Optional[str]=None, - actual_extra: bool=False, - scrubs: Optional[List[Tuple[str, str]]]=None, + file_pattern: Optional[str] = None, + actual_extra: bool = False, + scrubs: Optional[List[Tuple[str, str]]] = None, ) -> None: """Compare files matching `file_pattern` in `expected_dir` and `actual_dir`. diff --git a/tests/helpers.py b/tests/helpers.py index 0f958a39..1c4b2f96 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -64,9 +64,9 @@ def run_command(cmd: str) -> Tuple[int, str]: def make_file( filename: str, - text: str="", - bytes: bytes=b"", - newline: Optional[str]=None, + text: str = "", + bytes: bytes = b"", + newline: Optional[str] = None, ) -> str: """Create a file for testing. @@ -154,7 +154,7 @@ class CheckUniqueFilenames: return self.wrapped(filename, *args, **kwargs) -def re_lines(pat: str, text: str, match: bool=True) -> List[str]: +def re_lines(pat: str, text: str, match: bool = True) -> List[str]: """Return a list of lines selected by `pat` in the string `text`. If `match` is false, the selection is inverted: only the non-matching @@ -167,7 +167,7 @@ def re_lines(pat: str, text: str, match: bool=True) -> List[str]: return [l for l in text.splitlines() if bool(re.search(pat, l)) == match] -def re_lines_text(pat: str, text: str, match: bool=True) -> str: +def re_lines_text(pat: str, text: str, match: bool = True) -> str: """Return the multi-line text of lines selected by `pat`.""" return "".join(l + "\n" for l in re_lines(pat, text, match=match)) @@ -320,8 +320,8 @@ def assert_coverage_warnings( @contextlib.contextmanager def swallow_warnings( - message: str=r".", - category: Type[Warning]=CoverageWarning, + message: str = r".", + category: Type[Warning] = CoverageWarning, ) -> Iterator[None]: """Swallow particular warnings. diff --git a/tests/mixins.py b/tests/mixins.py index 586dcac5..d207f779 100644 --- a/tests/mixins.py +++ b/tests/mixins.py @@ -81,9 +81,9 @@ class TempDirMixin: def make_file( self, filename: str, - text: str="", - bytes: bytes=b"", - newline: Optional[str]=None, + text: str = "", + bytes: bytes = b"", + newline: Optional[str] = None, ) -> str: """Make a file. See `tests.helpers.make_file`""" # pylint: disable=redefined-builtin # bytes diff --git a/tests/test_api.py b/tests/test_api.py index 0eb73350..1c565421 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1062,7 +1062,7 @@ class TestRunnerPluginTest(CoverageTest): way they do. """ - def pretend_to_be_nose_with_cover(self, erase: bool=False, cd: bool=False) -> None: + def pretend_to_be_nose_with_cover(self, erase: bool = False, cd: bool = False) -> None: """This is what the nose --with-cover plugin does.""" self.make_file("no_biggie.py", """\ a = 1 @@ -1492,7 +1492,7 @@ class CombiningTest(CoverageTest): class ReportMapsPathsTest(CoverageTest): """Check that reporting implicitly maps paths.""" - def make_files(self, data: str, settings: bool=False) -> None: + def make_files(self, data: str, settings: bool = False) -> None: """Create the test files we need for line coverage.""" src = """\ if VER == 1: diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 13b6e73e..6caac307 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -98,7 +98,7 @@ class BaseCmdLineTest(CoverageTest): def mock_command_line( self, args: str, - options: Optional[Mapping[str, TConfigValueIn]]=None, + options: Optional[Mapping[str, TConfigValueIn]] = None, ) -> Tuple[mock.Mock, int]: """Run `args` through the command line, with a Mock. @@ -131,8 +131,8 @@ class BaseCmdLineTest(CoverageTest): self, args: str, code: str, - ret: int=OK, - options: Optional[Mapping[str, TConfigValueIn]]=None, + ret: int = OK, + options: Optional[Mapping[str, TConfigValueIn]] = None, ) -> None: """Assert that the `args` end up executing the sequence in `code`.""" called, status = self.mock_command_line(args, options=options) @@ -175,9 +175,9 @@ class BaseCmdLineTest(CoverageTest): def cmd_help( self, args: str, - help_msg: Optional[str]=None, - topic: Optional[str]=None, - ret: int=ERR, + help_msg: Optional[str] = None, + topic: Optional[str] = None, + ret: int = ERR, ) -> None: """Run a command line, and check that it prints the right help. @@ -1129,10 +1129,10 @@ class CoverageReportingFake: def __init__( self, report_result: float, - html_result: float=0, - xml_result: float=0, - json_report: float=0, - lcov_result: float=0, + html_result: float = 0, + xml_result: float = 0, + json_report: float = 0, + lcov_result: float = 0, ) -> None: self.config = CoverageConfig() self.report_result = report_result diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py index c80136c4..3360094b 100644 --- a/tests/test_concurrency.py +++ b/tests/test_concurrency.py @@ -207,7 +207,7 @@ class ConcurrencyTest(CoverageTest): code: str, concurrency: str, the_module: ModuleType, - expected_out: Optional[str]=None, + expected_out: Optional[str] = None, ) -> None: """Run some concurrency testing code and see that it was all covered. @@ -460,8 +460,8 @@ class MultiprocessingTest(CoverageTest): the_module: ModuleType, nprocs: int, start_method: str, - concurrency: str="multiprocessing", - args: str="", + concurrency: str = "multiprocessing", + args: str = "", ) -> None: """Run code using multiprocessing, it should produce `expected_out`.""" self.make_file("multi.py", code) diff --git a/tests/test_data.py b/tests/test_data.py index 8ed4f842..ab4e03f7 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -88,7 +88,7 @@ TCoverageData = Callable[..., CoverageData] def assert_line_counts( covdata: CoverageData, counts: Mapping[str, int], - fullpath: bool=False, + fullpath: bool = False, ) -> None: """Check that the line_counts of `covdata` is `counts`.""" assert line_counts(covdata, fullpath) == counts diff --git a/tests/test_files.py b/tests/test_files.py index fe6c36a2..35270e7b 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -133,10 +133,10 @@ def test_flat_rootname(original: str, flat: str) -> None: def globs_to_regex_params( patterns: Iterable[str], - case_insensitive: bool=False, - partial: bool=False, - matches: Iterable[str]=(), - nomatches: Iterable[str]=(), + case_insensitive: bool = False, + partial: bool = False, + matches: Iterable[str] = (), + nomatches: Iterable[str] = (), ) -> Iterator[Any]: """Generate parameters for `test_globs_to_regex`. @@ -399,7 +399,7 @@ class PathAliasesTest(CoverageTest): expected = files.canonical_filename(out) assert mapped == expected - def assert_unchanged(self, aliases: PathAliases, inp: str, exists: bool=True) -> None: + def assert_unchanged(self, aliases: PathAliases, inp: str, exists: bool = True) -> None: """Assert that `inp` mapped through `aliases` is unchanged.""" assert aliases.map(inp, exists=lambda p: exists) == inp diff --git a/tests/test_html.py b/tests/test_html.py index 5960962e..8893993c 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -55,8 +55,8 @@ class HtmlTestHelpers(CoverageTest): def run_coverage( self, - covargs: Optional[Dict[str, Any]]=None, - htmlargs: Optional[Dict[str, Any]]=None, + covargs: Optional[Dict[str, Any]] = None, + htmlargs: Optional[Dict[str, Any]] = None, ) -> float: """Run coverage.py on main_file.py, and create an HTML report.""" self.clean_local_file_imports() @@ -136,7 +136,7 @@ class FileWriteTracker: def __init__(self, written: Set[str]) -> None: self.written = written - def open(self, filename: str, mode: str="r") -> IO[str]: + def open(self, filename: str, mode: str = "r") -> IO[str]: """Be just like `open`, but write written file names to `self.written`.""" if mode.startswith("w"): self.written.add(filename.replace('\\', '/')) @@ -158,8 +158,8 @@ class HtmlDeltaTest(HtmlTestHelpers, CoverageTest): def run_coverage( self, - covargs: Optional[Dict[str, Any]]=None, - htmlargs: Optional[Dict[str, Any]]=None, + covargs: Optional[Dict[str, Any]] = None, + htmlargs: Optional[Dict[str, Any]] = None, ) -> float: """Run coverage in-process for the delta tests. @@ -658,7 +658,7 @@ def filepath_to_regex(path: str) -> str: def compare_html( expected: str, actual: str, - extra_scrubs: Optional[List[Tuple[str, str]]]=None, + extra_scrubs: Optional[List[Tuple[str, str]]] = None, ) -> None: """Specialized compare function for our HTML files.""" __tracebackhide__ = True # pytest, please don't show me this function. diff --git a/tests/test_lcov.py b/tests/test_lcov.py index 95bc5fee..30065a8d 100644 --- a/tests/test_lcov.py +++ b/tests/test_lcov.py @@ -46,7 +46,7 @@ class LcovTest(CoverageTest): self.assertAlmostEqual(cuboid_volume(5.5),166.375) """) - def get_lcov_report_content(self, filename: str="coverage.lcov") -> str: + def get_lcov_report_content(self, filename: str = "coverage.lcov") -> str: """Return the content of an LCOV report.""" with open(filename, "r") as file: return file.read() diff --git a/tests/test_xml.py b/tests/test_xml.py index a6a15281..005f9d5a 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -37,7 +37,7 @@ class XmlTestHelpers(CoverageTest): self.start_import_stop(cov, "main") return cov - def make_tree(self, width: int, depth: int, curdir: str=".") -> None: + def make_tree(self, width: int, depth: int, curdir: str = ".") -> None: """Make a tree of packages. Makes `width` directories, named d0 .. d{width-1}. Each directory has @@ -457,7 +457,7 @@ class XmlPackageStructureTest(XmlTestHelpers, CoverageTest): assert [elt.text for elt in elts] == ["src"] -def compare_xml(expected: str, actual: str, actual_extra: bool=False) -> None: +def compare_xml(expected: str, actual: str, actual_extra: bool = False) -> None: """Specialized compare function for our XML files.""" source_path = coverage.files.relative_directory().rstrip(r"\/") |