feat(checker): BSK-E0153 constructor-to-callable conversion (conformance constructors_callable PASS)#73
Merged
Conversation
…ormance constructors_callable PASS) Implements the typing-spec rule 'Converting a constructor to callable'. A class object flowing through an identity-over-callable function (def f(cb: Callable[P, R]) -> Callable[P, R]) gains the class's constructor-to-callable signature; calls to the bound variable are now validated against it (arity, keyword names, and list[T] TypeVar binding consistency). Signature derivation priority: metaclass __call__, then __new__ (when it returns a non-Self/non-class type), then __init__. Flips conformance constructors_callable.py to PASS (12/12, 0 FP), raising the suite to 136/146 (93.15%); conformance threshold ratcheted 92 -> 93. Also extracts shared::method_name_map and migrates e0041/e0074/e0111/e0144 to it, removing 4 copies of the (class, method) -> Vec<&FunctionInfo> builder (net DRY win).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Adds checker rule BSK-E0153 implementing the typing-spec "Converting a constructor to callable" rule, flipping the
constructors_callable.pyPEP conformance file to PASS (suite 135→136/146, 93.15%).What Was Added?
crates/basilisk-checker/src/rules/e0153.rs—ConstructorCallableMisuserule. When a class object flows through an identity-over-callable function (def f(cb: Callable[P, R]) -> Callable[P, R]), the bound variable inherits the class's constructor-to-callable signature, and calls to it are validated. Signature derivation priority: metaclass__call__→__new__(when it returns a non-Self/non-class type, e.g.-> int/-> Proxy/-> Any, so__init__is ignored) →__init__→ empty. Detects: too few / too many positional args, unknown keyword names, and inconsistentlist[T]TypeVar bindings. Conservative: starred/**kwargsunpacking suppresses arity checks.crates/basilisk-checker/tests/e0153_tests.rs— 8 e2e tests (invalid calls, valid calls, metaclass passthrough,__new__-controls, float/bytes element conflict, heterogeneous list, plus isolation guards: non-identity wrappers and direct class aliases must NOT fire).shared::method_name_map()— shared(class, method) → Vec<&FunctionInfo>builder.What Was Changed or Deleted?
e0153::ConstructorCallableMisusein the rule registry.e0041,e0074,e0111,e0144toshared::method_name_map, deleting 4 copies of the identical inline method-map builder.92 → 93incoverage-thresholds.json(now 136/146 = 93.15%).conformance/conformance_status.csv(constructors_callable.py→ PASS, 12 caught / 0 missed / 0 FP).How Do The Automated Tests Prove It Works?
e0153_tests: 8 tests pass — e.g.invalid_calls_emit_e0153asserts exactly 4 diagnostics ("missing required argumentx", "Unexpected keyword argumenty", "too many positional argument", "Inconsistent binding for type variableT");valid_calls_do_not_emit_e0153,metaclass_call_accepts_any_arguments, andnon_identity_wrapper_is_not_trackedassert zero diagnostics.conformance_score: gate prints93% (136/146) >= 93% threshold — PASS;constructors_callable.pynow caught=12, missed=0, and the suite-wide false-positive total is unchanged at 170 (zero new FPs).basilisk-checkerat 94% ≥ 93%; all crate thresholds met; full workspace test suite green.cargo clippy --workspace --all-targets -D warningsandcargo fmt --checkclean.Spec / Doc Changes
docs/specs/CHECKER-ARCHITECTURE-SPEC.md: new section{#CHKARCH-DIAG-CTOR-CALLABLE}+BSK-E0153reference-table row (code/tests cross-reference this spec ID).website/src/docs/rules/index.md+zh/mirror: addedBSK-E0153row.docs/plans/CHECKER-PEP-CONFORMANCE-PLAN.md: score updated to 136/146;constructors_callable.pymarked done.Breaking Changes