fix(typing): set eq_default=False for autoinit - #95
Conversation
autoinit only synthesizes __init__, so eq_default must be false to preserve TreeClass's inherited hashability in static analysis.
|
Added two small CI compatibility follow-ups: replaced the removed |
|
Hello @ASEM000, when you have a chance, could you take a look at this PR? FDTDX relies heavily on pytreeclass, so I’d really appreciate your review. Thank you! |
|
I will take a look asap. |
|
looks fine to me. |
|
can you bump up the version to 11.1 @yspkm and add a changelog entry? |
Thank you for taking a look. I've bumped the version to 0.11.1 and added the changelog entry. btw fdtdx currently tests against 3.11 and 3.14, so I will keep an eye on compatibility and follow up if needed. |
d6e49cd to
832e5ef
Compare
Hello @ASEM000, version bumped to 0.11.1 with the changelog entry added. All checks are green now. Thanks! |
|
Merged @yspkm Thanks. Will publish tomorrow |
Thank you for merging this! |
What changed
Set
eq_default=Falsein the@dataclass_transformmetadata forautoinit.This affects static typing metadata only; runtime behavior is unchanged.
Why
While validating an FDTDX contribution, I found that ty 0.0.67+ reports
@autoinitTreeClasssubclasses as incompatible withHashable.The relevant check was introduced in ty 0.0.67, released on August 5, 2026. It rejects unhashable objects for
Hashableprotocols. The same checks pass with ty 0.0.66 and fail with ty 0.0.69.autoinitonly synthesizes__init__; it does not generate__eq__or__hash__. However, the impliciteq_default=Truecauses type checkers to assume dataclass-style equality and treat the inheritedTreeClass.__hash__as disabled.Setting
eq_default=Falsealigns the typing metadata with the existing runtime behavior and preserves the inferred hashability ofTreeClasssubclasses.Validation
Evidence