lib.Types: Read __abstractmethods__ via getattr() #89
Loading…
Reference in a new issue
No description provided.
Delete branch "jan/feature/20260907-lib-types-read-abstractmethods-via-getattr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
lib.Types: Read abstractmethods via getattr()
LoadTypes._classes() reads the abstractmethods attribute of each class that inspect.getmembers() returns for its debug output. mypy 2.2.0 allows this, mypy 2.3.1 doesn't: It now types those classes as type[object] instead of Any. The attribute itself is only declared on the ABCMeta metaclass, so the direct access fails the type check.
Read the attribute through getattr() with an 'unknown' fallback string, and annotate the variable explicitly. The runtime behavior is unchanged, since the attribute exists whenever inspect.isabstract() is true, and the call satisfies the checker.