Skip to content

feat(lower): erase ABC/Protocol bases and typing overloads (T2-2) - #124

Draft
espetro wants to merge 1 commit into
masterfrom
work/t2-abc-protocol-erasure
Draft

espetro wants to merge 1 commit into
masterfrom
work/t2-abc-protocol-erasure

Conversation

@espetro

@espetro espetro commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Tier-2 erasure per .agents/plans/2026-10-18-tiered-lowering-and-typefacts.md — static-typing constructs vanish before emission; no CPython runtime enforcement.

  • abc joins _ERASED_MODULES (with typing), so ABC/ABCMeta/Protocol/abstractmethod resolve through type_aliases or an erased _resolve_module triple for both from abc import X and abc.X spellings.
  • _collect_class skips _ERASED_BASES bases and metaclass=ABCMeta keywords; classes off a Protocol base get info["protocol"] and declaration-only members (.../pass/docstring) are skipped rather than emitted.
  • _method_decorator/_accept_module_function filter _ERASED_DECORATORS (abstractmethod, overload) first: @property @abstractmethod still resolves to a property, and only the final undecorated @overload implementation lowers (resolution stays the checker's job).
  • _expect/_fill_args relax types_equal via _accepts_protocol: a Protocol-annotated slot accepts any subclass of the erased marker class — object-ish, not structural; unrelated classes/scalars still fail.
  • Still fenced: isinstance/issubclass on a Protocol (new PS2001 message), @runtime_checkable (existing PS1201). Divergences (e.g. ABC() instantiates) documented in docs/refused-features.md.
  • New tests/test_t2_abc_protocol.py (6 oracle-diff tests, all pass); pyjwt fixture pin drops 103 → 101 since its from abc import ABC, abstractmethod now erases.

Census (frozen tests/test_census_self.py untouched): modules 27, fences 1028 (+5 vs master 1023 — new helpers add self-parse fences), lines 20479. Full suite: 9 failures, 7 verified identical on clean master (planted except X, Y: syntax errors in benchmarks/compat2/cache.py/examples/gates_probe.py also break 8-file collection there); remaining two are the frozen census pin and the pyjwt pin updated here. ruff check/ruff format clean on changed files.

Link to Devin session: https://app.devin.ai/sessions/600cde62c8144a618bf49c577003129d
Open in Devin Desktop: https://app.devin.ai/desktop/session/600cde62c8144a618bf49c577003129d?variant=devin
Requested by: @espetro

Tier-2 erasure per .agents/plans/2026-10-18-tiered-lowering-and-typefacts.md:
- 'abc' joins the erased modules; ABC/ABCMeta/Protocol bases and
  metaclass=ABCMeta drop out of _collect_class, so the classes lower
  as plain classes.
- @abstractmethod/@overload decorators erase through Name or
  attribute spellings; only the final undecorated @overload
  implementation lowers, and declaration-only Protocol/abstract
  bodies (...) are skipped instead of emitted.
- Classes collected off a Protocol base are flagged 'protocol'; a
  Protocol-annotated parameter accepts any subclass of the erased
  marker class (no structural check, no runtime enforcement).
- isinstance/issubclass on a Protocol and @runtime_checkable stay
  fenced; divergences documented in docs/refused-features.md.
- tests/test_t2_abc_protocol.py covers the oracle diffs and the
  fences that stay; pyjwt fixture pin drops 103 -> 101 fences now
  that its abc imports erase.
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying pyscriptc with  Cloudflare Pages  Cloudflare Pages

Latest commit: 32d5dd5
Status: ✅  Deploy successful!
Preview URL: https://e7ee7b6a.pyscriptc.pages.dev
Branch Preview URL: https://work-t2-abc-protocol-erasure.pyscriptc.pages.dev

View logs

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant