diff --git a/mypy/report.py b/mypy/report.py index 9e1e156236f2..37b7497f1371 100644 --- a/mypy/report.py +++ b/mypy/report.py @@ -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):