Spun off from #35 (closed in 2.2.0): the immutability cleanup for unpythonic.llist.cons (and any future "frozen" types in this codebase) shipped raising TypeError to preserve API stability under the 2.x compatibility promise.
Standard library convention since Python 3.7 is dataclasses.FrozenInstanceError for "tried to mutate a frozen instance." Aligning is desirable for ecosystem consistency, but FrozenInstanceError subclasses AttributeError, not TypeError. Switching is therefore a breaking change for any user code catching TypeError from a cons mutation attempt — appropriate for a major-version bump.
Scope
unpythonic/llist.py: cons.__setattr__ and cons.__delattr__ raise dataclasses.FrozenInstanceError instead of TypeError.
- Tests: update
unpythonic/tests/test_llist.py immutability assertions to expect FrozenInstanceError (or AttributeError).
- CHANGELOG: Changed (breaking) entry under 3.0.0.
- Audit any other "frozen" types added between now and 3.0.0 for the same alignment.
Notes
assignonce.__delattr__ (added in 2.2.0) raises AttributeError, which already aligns naturally — leave alone.
frozendict does not currently lock down attribute writes (only mapping writes); this issue is about types whose contract is "frozen instance."
— Claude (Opus 4.7)
Spun off from #35 (closed in 2.2.0): the immutability cleanup for
unpythonic.llist.cons(and any future "frozen" types in this codebase) shipped raisingTypeErrorto preserve API stability under the 2.x compatibility promise.Standard library convention since Python 3.7 is
dataclasses.FrozenInstanceErrorfor "tried to mutate a frozen instance." Aligning is desirable for ecosystem consistency, butFrozenInstanceErrorsubclassesAttributeError, notTypeError. Switching is therefore a breaking change for any user code catchingTypeErrorfrom aconsmutation attempt — appropriate for a major-version bump.Scope
unpythonic/llist.py:cons.__setattr__andcons.__delattr__raisedataclasses.FrozenInstanceErrorinstead ofTypeError.unpythonic/tests/test_llist.pyimmutability assertions to expectFrozenInstanceError(orAttributeError).Notes
assignonce.__delattr__(added in 2.2.0) raisesAttributeError, which already aligns naturally — leave alone.frozendictdoes not currently lock down attribute writes (only mapping writes); this issue is about types whose contract is "frozen instance."— Claude (Opus 4.7)