Skip to content

Commit ab3b98f

Browse files
authored
Fix crash with report generation on namespace packages (#13733)
Fixes #11234
1 parent 780534b commit ab3b98f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mypy/report.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,12 @@ def should_skip_path(path: str) -> bool:
140140

141141
def iterate_python_lines(path: str) -> Iterator[tuple[int, str]]:
142142
"""Return an iterator over (line number, line text) from a Python file."""
143-
with tokenize.open(path) as input_file:
144-
yield from enumerate(input_file, 1)
143+
try:
144+
with tokenize.open(path) as input_file:
145+
yield from enumerate(input_file, 1)
146+
except IsADirectoryError:
147+
# can happen with namespace packages
148+
pass
145149

146150

147151
class FuncCounterVisitor(TraverserVisitor):

0 commit comments

Comments
 (0)