Skip to content

Commit

Permalink
Fix crash with report generation on namespace packages (#13733)
Browse files Browse the repository at this point in the history
Fixes #11234
  • Loading branch information
hauntsaninja authored Sep 27, 2022
1 parent 780534b commit ab3b98f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mypy/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ 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."""
with tokenize.open(path) as input_file:
yield from enumerate(input_file, 1)
try:
with tokenize.open(path) as input_file:
yield from enumerate(input_file, 1)
except IsADirectoryError:
# can happen with namespace packages
pass


class FuncCounterVisitor(TraverserVisitor):
Expand Down

0 comments on commit ab3b98f

Please sign in to comment.