You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4ccb476
Browse filesBrowse the repository at this point in the historyBrowse files
authored
Fix beartype claw skipping BooleanLevel; make claw warnings fatal in tests (#154)
## The bug
Every `import ttsim` (and so every `import gettsim`) emitted:
```
BeartypeClawDecorWarning: Function namedtuple_BooleanLevel.BooleanLevel.__new__()
not decoratable by @beartype, as:
BeartypeDecorHintForwardRefException: Forward reference 'str | None'
not valid Python attribute name.
```
`BooleanLevel` in `_unit_inference.py` was a `NamedTuple`. Under `from
__future__ import annotations`, the `__new__` that
`collections.namedtuple` synthesizes carries *stringified* annotations,
which beartype resolves as forward references: a bare name like `bool`
resolves, `str | None` does not. The claw therefore skipped the class —
runtime checking on it was silently absent, not merely noisy.
## The fix
Make `BooleanLevel` a `@dataclass(frozen=True)` (which the project
prefers anyway) and read its fields by attribute at the three unpacking
call sites. Verified empirically that a frozen dataclass with the
identical `str | None` field decorates cleanly under the claw while the
`NamedTuple` form does not.
## Making it loud
The warning had been scrolling past unnoticed in CI.
`BeartypeClawDecorWarning` is now `error::` in
`ini_options.filterwarnings`, so any future skipped decoration fails the
suite.
The `@interface_input` metadata dataclasses are the one known-benign
case (a non-callable data holder has nothing to check) and stay exempt.
That exemption needs to be in the pytest config as well as in
`ttsim/__init__.py`, because pytest resets warning filters per item —
which is why 7 of them were showing up in `pytest ttsim/tests` output
despite the import-time filter.
`tests/test_beartype_gate.py` gains
`test_import_leaves_no_claw_decoration_skipped`, covering plain `import
ttsim` outside pytest too. Written first, confirmed red on the
`BooleanLevel` warning, green after the fix.
## Verification
- `pytest ttsim/tests`: 1674 passed, 6 skipped, 0 claw warnings.
- Reverting only the `_unit_inference.py` change makes the suite error
out, confirming the guard fires.
- gettsim and gettsim-personas suites: 0 claw warnings, all green.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01VCkEDhUCi4aJ6uLGTQeeNH
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
0 commit comments