8000 Fix crash with report generation on namespace packages by hauntsaninja · Pull Request #13733 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Fix crash with report generation on namespace packages #13733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix crash with report generation on namespace packages
Fixes #11234
  • Loading branch information
hauntsaninja committed Sep 26, 2022
commit 58a4e1d280cb11d571e96f48fff8bbe4b7ed3f47
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