diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-12 21:01:14 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-12 21:04:26 -0500 |
commit | 2be37e3d695af882ccedd71168f82ffd12bca961 (patch) | |
tree | 2d5c0242f7ebfc416b960ed3d46fa25a441ac638 | |
parent | b5b223723fd1aeaa8ed650b8440b4b8c08f8e378 (diff) | |
download | python-coveragepy-git-2be37e3d695af882ccedd71168f82ffd12bca961.tar.gz |
mypy: turn on disallow_untyped_calls
-rw-r--r-- | coverage/data.py | 1 | ||||
-rw-r--r-- | coverage/xmlreport.py | 23 | ||||
-rw-r--r-- | pyproject.toml | 2 |
3 files changed, 16 insertions, 10 deletions
diff --git a/coverage/data.py b/coverage/data.py index ee4f007d..c737d593 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -35,6 +35,7 @@ def line_counts(data: CoverageData, fullpath: bool = False) -> Dict[str, int]: """ summ = {} + filename_fn: Callable[[str], str] if fullpath: # pylint: disable=unnecessary-lambda-assignment filename_fn = lambda f: f diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py index 86fdc18f..6867f2e9 100644 --- a/coverage/xmlreport.py +++ b/coverage/xmlreport.py @@ -12,7 +12,7 @@ import time import xml.dom.minidom from dataclasses import dataclass -from typing import Dict, IO, Iterable, Optional, TYPE_CHECKING, cast +from typing import Any, Dict, IO, Iterable, Optional, TYPE_CHECKING, cast from coverage import __url__, __version__, files from coverage.misc import isolate_module, human_sorted, human_sorted_items @@ -48,6 +48,11 @@ class PackageData: branches: int +def appendChild(parent: Any, child: Any) -> None: + """Append a child to a parent, in a way mypy will shut up about.""" + parent.appendChild(child) + + class XmlReporter: """A reporter for writing Cobertura-style XML coverage results.""" @@ -103,9 +108,9 @@ class XmlReporter: # Populate the XML DOM with the source info. for path in human_sorted(self.source_paths): xsource = self.xml_out.createElement("source") - xsources.appendChild(xsource) + appendChild(xsources, xsource) txt = self.xml_out.createTextNode(path) - xsource.appendChild(txt) + appendChild(xsource, txt) lnum_tot, lhits_tot = 0, 0 bnum_tot, bhits_tot = 0, 0 @@ -116,11 +121,11 @@ class XmlReporter: # Populate the XML DOM with the package info. for pkg_name, pkg_data in human_sorted_items(self.packages.items()): xpackage = self.xml_out.createElement("package") - xpackages.appendChild(xpackage) + appendChild(xpackages, xpackage) xclasses = self.xml_out.createElement("classes") - xpackage.appendChild(xclasses) + appendChild(xpackage, xclasses) for _, class_elt in human_sorted_items(pkg_data.elements.items()): - xclasses.appendChild(class_elt) + appendChild(xclasses, class_elt) xpackage.setAttribute("name", pkg_name.replace(os.sep, '.')) xpackage.setAttribute("line-rate", rate(pkg_data.hits, pkg_data.lines)) if has_arcs: @@ -187,10 +192,10 @@ class XmlReporter: xclass: xml.dom.minidom.Element = self.xml_out.createElement("class") - xclass.appendChild(self.xml_out.createElement("methods")) + appendChild(xclass, self.xml_out.createElement("methods")) xlines = self.xml_out.createElement("lines") - xclass.appendChild(xlines) + appendChild(xclass, xlines) xclass.setAttribute("name", os.path.relpath(rel_name, dirname)) xclass.setAttribute("filename", rel_name.replace("\\", "/")) @@ -219,7 +224,7 @@ class XmlReporter: 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)) - xlines.appendChild(xline) + appendChild(xlines, xline) class_lines = len(analysis.statements) class_hits = class_lines - len(analysis.missing) diff --git a/pyproject.toml b/pyproject.toml index 90c4f080..4f2b5936 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ check_untyped_defs = true disallow_any_generics = true disallow_incomplete_defs = true disallow_subclassing_any = true -disallow_untyped_calls = false +disallow_untyped_calls = true disallow_untyped_decorators = false disallow_untyped_defs = true follow_imports = "silent" |