lib.Types: Read __abstractmethods__ via getattr() #89
1 changed files with 4 additions and 1 deletions
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
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
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>
commit
ff6e13e09f
|
|
@ -102,7 +102,10 @@ class LoadTypes(Types[T]): # export
|
||||||
self._debug(f'o "{name}" has wrong name')
|
self._debug(f'o "{name}" has wrong name')
|
||||||
continue
|
continue
|
||||||
if inspect.isabstract(c):
|
if inspect.isabstract(c):
|
||||||
self._debug(f'o "{name}" is abstract: {c.__abstractmethods__}')
|
abstract: frozenset[str] = getattr(
|
||||||
|
c, '__abstractmethods__', frozenset()
|
||||||
|
)
|
||||||
|
self._debug(f'o "{name}" is abstract: {abstract}')
|
||||||
continue
|
continue
|
||||||
if self.__type_filter:
|
if self.__type_filter:
|
||||||
for tp in self.__type_filter:
|
for tp in self.__type_filter:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue