Skip to content

Close small library gaps: typing, enum flags, dataclasses, json options, atexit, decorators - #234

Merged
ets-public merged 1 commit into
mainfrom
claude/project-thread-g9efi4
Nov 6, 2026
Merged

ets-public merged 1 commit into
mainfrom
claude/project-thread-g9efi4

Conversation

@ets-public

Copy link
Copy Markdown
Owner

Requested by Adam · project thread

What this changes

Roadmap item 3 (small library gaps: tenacity, json/orjson, dataclasses, typing, enum). Native output matches CPython or the build is refused at build time.

Silent wrong answers on main, now fixed:

  • The typed build dropped every decorator it did not implement (@tenacity.retry, @atexit.register, user decorators). Those files now go to the dynamic build (typed_guard::odd_decorator).
  • The dynamic build mapped every typing name to object: NamedTuple classes failed and isinstance(x, Iterable) was always True (the typed build got that isinstance wrong too).
  • json.loads ignored object_hook, object_pairs_hook, parse_float, parse_int, parse_constant and strict. The typed json.dumps ignored allow_nan, default, check_circular and skipkeys.
  • format() of a (str, Enum) member, '%d' % IntEnum, __doc__ (always None), __hash__ results above 2**61, and del not calling __delattr__.

New native support:

  • typing: NamedTuple, TypedDict, Generic, Protocol, TypeVar, NewType, cast, assert_never, reveal_type, TYPE_CHECKING and the decorators (src/dynpy/typing.rs checks at build time, rt_typing.rs is the runtime).
  • enum: IntEnum, StrEnum, Flag and IntFlag, after enum.py 3.13.
  • dataclasses: rewritten after dataclasses.py (Field objects, KW_ONLY, InitVar, ClassVar, the hash table, FrozenInstanceError).
  • json: every option, cls= with JSONEncoder/JSONDecoder subclasses, bytes input, and CPython's errors.
  • atexit: native. Bridged atexit callbacks used to fail at exit with "from another thread".
  • orjson: keyword arguments through both bridges failed. Keyword names are now interned (tenacity and orjson stay CPython-run and now match).

How it was tested

  • sh tools/ci_local.sh passes (result added below)
  • A test under tests/ covers the change: tests/lib/{typing_namedtuple,typing_forms,enum_mixins,enum_flags,dataclasses_more,json_hooks,json_dumps_kwargs,atexit_native}.py, each diffed against python3 3.13
  • A line under "Unreleased" in CHANGELOG.md

Generated by Claude Code

…ns, atexit, decorators

The typed build dropped decorators it did not know (tenacity's @Retry,
@atexit.register, user decorators); those now go to the dynamic build.
The dynamic build now runs typing (NamedTuple, TypedDict, Generic,
Protocol, TypeVar, NewType, cast...), IntEnum/StrEnum/Flag/IntFlag,
dataclasses after CPython's dataclasses.py, every json option (hooks,
cls=, bytes input, circular and allow_nan checks) and atexit natively,
matching CPython; anything else typing-related is refused at build time.
Keyword names passed to bridged libraries are interned (orjson).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0136hkZjqxLQw3R2836g7wUD
@ets-public
ets-public marked this pull request as ready for review November 6, 2026 11:49
@ets-public
ets-public merged commit 835d76a into main Nov 6, 2026
4 checks passed
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.

2 participants