stubtest: distinguish metaclass attributes from class attributes #18314
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the runtime attribute of a class is actually from the metaclass, consider it to be MISSING at runtime.
This only occurs a couple times in the stdlib: it shows up when a descriptor is present on the metaclass but not the class, and we want to lie in the stub and say it's a thing on the class anyway.
I found this after noticing that
enum.auto.__or__
had a comment that said itdidn't exist at runtime, but stubtest thought that it actually did. The issue is that on 3.10+,
type.__or__
is defined for the purpose of Union types, and stubtest doesn't know the difference betweentype.__or__
and__or__
on the actual class.Currently this matches on these things in typeshed's stdlib:
This MR doesn't resolve any allowlist entries for typeshed, and it doesn't create any new ones either, but should generate more accurate error messages in this particular edge case.