lib.Types: Restrict LoadTypes to ABC-derived classes #90

Merged
Jan Lindemann merged 1 commit from jan/feature/20260907-lib-types-restrict-loadtypes-to-abc-derived-classes into master 2026-09-07 09:21:25 +02:00 AGit

lib.Types: Restrict LoadTypes to ABC-derived classes

The previous commit reads __abstractmethods__ via a getattr() with an empty frozenset fallback, because in mypy 2.3.1 the scanned classes are typed as type[object], which does not declare the attribute.

Add is_abc_class() as a TypeGuard, and skip the classes it rejects with a debug line: LoadTypes now yields only ABC-derived classes. The guard narrows to the classes that carry the attribute, so that the debug line can now read __abstractmethods__ directly.

The command loaders are unaffected: every class they load is derived from AbstractCmd, and hence from ABC. For loads that rely on the name filter alone, plain classes are now skipped instead of being yielded.

#### lib.Types: Restrict LoadTypes to ABC-derived classes The previous commit reads `__abstractmethods__` via a `getattr()` with an empty frozenset fallback, because in mypy 2.3.1 the scanned classes are typed as `type[object]`, which does not declare the attribute. Add `is_abc_class()` as a `TypeGuard`, and skip the classes it rejects with a debug line: LoadTypes now yields only ABC-derived classes. The guard narrows to the classes that carry the attribute, so that the debug line can now read `__abstractmethods__` directly. The command loaders are unaffected: every class they load is derived from AbstractCmd, and hence from ABC. For loads that rely on the name filter alone, plain classes are now skipped instead of being yielded.
lib.Types: Restrict LoadTypes to ABC-derived classes
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m18s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m18s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 3m50s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m5s
CI / Packaging test (push) Successful in 0s
281a8f383e
The previous commit reads __abstractmethods__ via a getattr() with an empty
frozenset fallback, because in mypy 2.3.1 the scanned classes are typed as
type[object], which does not declare the attribute.

Add is_abc_class() as a TypeGuard, and skip the classes it rejects with a
debug line: LoadTypes now yields only ABC-derived classes. The guard
narrows to the classes that carry the attribute, so that the debug line can
now read __abstractmethods__ directly.

The command loaders are unaffected: every class they load is derived from
AbstractCmd, and hence from ABC. For loads that rely on the name filter
alone, plain classes are now skipped instead of being yielded.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2
Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-09-07 09:12:44 +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!90
No description provided.