mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-10-26 06:43:15 +08:00
Round 9 closes 2 of the 3 remaining stress gaps from Round 8: TypedDict literal-key subscript: - d["foo"] where d: TD with class-body annotation `foo: Foo` returns the field's type. Routes through the existing class-body-annotation field registry (Round 4): TypedDict subclasses already register their fields the same way. The subscript branch in py_eval_expr_type now detects NAMED container + literal-string key and looks up the field via py_lookup_field. Strips both single and double quotes. Early-return narrowing (post-block flow): - if not isinstance(x, T): return / raise / break / continue — applies the *positive* narrow to the enclosing scope after the if-block when the consequence terminates. - if x is None: return — narrows x to non-None afterwards. - py_block_terminates detects return/raise/break/continue as the last statement of the body block. Subsequent code in the function sees the narrowed type. Match sequence pattern (tentative): - list_pattern / tuple_pattern handler added: bind capture-pattern elements to the subject's iterable element type; bind splat-pattern rest to list[elem]. Also walks more wrapper levels (case_pattern -> pattern -> _simple_pattern). Test still flags as KNOWN GAP because tree-sitter's pattern-wrapper structure for the bracket-form `[a, b]` in match/case differs in some grammar versions; documented as remaining gap pending grammar inspection. Stress test suite: 22/22 PASS. Hard-asserted patterns: namedtuple, typeddict, protocol, abc, with-as, except-as, isinstance-early-return, tuple-unpack, dict.items, slice, decorator-factory, property-setter, Self chain, diamond MRO, recursive types, nested closure, long method chains, generator delegation, async-gen for. Documented gaps: function-as-dict-value, match sequence pattern, lambda inference. Bench unchanged at 100% / 11.02 ms; total 2920 / 0.