lib.Types: Read __abstractmethods__ via getattr() #89

Merged
Jan Lindemann merged 1 commit from jan/feature/20260907-lib-types-read-abstractmethods-via-getattr into master 2026-09-07 07:17:01 +02:00 AGit

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.

#### 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.
lib.Types: Read __abstractmethods__ via getattr()
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m19s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m19s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m8s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m6s
CI / Packaging test (push) Successful in 0s
ff6e13e09f
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.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2
Signed-off-by: user.email <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-09-07 07:08:19 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!89
No description provided.