Skip to content

Conversation

@wyattscarpenter
Copy link
Contributor

@wyattscarpenter wyattscarpenter commented Oct 24, 2025

Fixes #18128. This fixes an Internal Error where namespace packages were not supported properly. This fix was inspired by @sterliakov noticing that this bug was very similar to #19843, which has a similar fix. Note that we use os.path.isdir(tree.path) instead of trying to catch an IsADirectoryError exception because of a bug on Windows which causes it to throw a PermissionError instead in the relevant situation, which makes except IsADirectoryError unreliable. (We also can't just except (IsADirectoryError, PermissionError) because what if there is an actual permission error?) Anyway, we just early-return — which, based on my manual testing and reading the code, seems to be the right thing to do here.

@wyattscarpenter wyattscarpenter marked this pull request as draft October 24, 2025 01:06
@github-actions

This comment has been minimized.

@wyattscarpenter wyattscarpenter marked this pull request as ready for review October 24, 2025 02:41
@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Collaborator

@sterliakov sterliakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, we have nothing to count in the namespace package directory itself, returning early looks reasonable. Nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IsADirectoryError for namespace packages when using --linecoverage-report

2 participants