Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stubtest: distinguish metaclass attributes from class attributes (#18314
) 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 it didn'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 between `type.__or__` and `__or__` on the actual class. Currently this matches on these things in typeshed's stdlib: ``` abc.ABCMeta.__abstractmethods__ builtins.object.__annotations__ enum.auto.__or__ enum.auto.__ror__ types.NotImplementedType.__call__ ``` 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.
- Loading branch information