From 4d3d7f47ebce9ee27d6ae87c34c8941c438cf353 Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Thu, 23 Oct 2025 21:17:35 -0700 Subject: [PATCH 1/2] add failing test testReportCoberturaCrashOnNamespacePackages --- test-data/unit/reports.test | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test-data/unit/reports.test b/test-data/unit/reports.test index 82c3869bb855..714610314c88 100644 --- a/test-data/unit/reports.test +++ b/test-data/unit/reports.test @@ -547,3 +547,37 @@ namespace_packages = True + +[case testReportCoberturaCrashOnNamespacePackages] +# cmd: mypy --cobertura-xml-report report -p folder +-- Regression test for https://github.com/python/mypy/issues/19843 +[file folder/subfolder/something.py] +-- This output is not important, but due to the way tests are run we need to check it. +[outfile report/cobertura.xml] + + + $PWD + + + + + + + + + + + + + + + + + + + + + + + + From a33382200b9cb2d5b4a0eb19fce3b0266aa73d5d Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Thu, 23 Oct 2025 21:18:52 -0700 Subject: [PATCH 2/2] Fix for windows. --- mypy/report.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mypy/report.py b/mypy/report.py index 39cd80ed38bf..90a62c8a4c7c 100644 --- a/mypy/report.py +++ b/mypy/report.py @@ -141,12 +141,9 @@ def should_skip_path(path: str) -> bool: def iterate_python_lines(path: str) -> Iterator[tuple[int, str]]: """Return an iterator over (line number, line text) from a Python file.""" - try: + if not os.path.isdir(path): # can happen with namespace packages with tokenize.open(path) as input_file: yield from enumerate(input_file, 1) - except IsADirectoryError: - # can happen with namespace packages - pass class FuncCounterVisitor(TraverserVisitor):