Skip to content

fix(typing): set eq_default=False for autoinit - #95

Merged
ASEM000 merged 4 commits into
ASEM000:mainfrom
yspkm:fix/autoinit-hashable-typing
Aug 17, 2026
Merged

fix(typing): set eq_default=False for autoinit#95
ASEM000 merged 4 commits into
ASEM000:mainfrom
yspkm:fix/autoinit-hashable-typing

Conversation

@yspkm

@yspkm yspkm commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

What changed

Set eq_default=False in the @dataclass_transform metadata for autoinit.

This affects static typing metadata only; runtime behavior is unchanged.

Why

While validating an FDTDX contribution, I found that ty 0.0.67+ reports @autoinit TreeClass subclasses as incompatible with Hashable.

The relevant check was introduced in ty 0.0.67, released on August 5, 2026. It rejects unhashable objects for Hashable protocols. The same checks pass with ty 0.0.66 and fail with ty 0.0.69.

autoinit only synthesizes __init__; it does not generate __eq__ or __hash__. However, the implicit eq_default=True causes type checkers to assume dataclass-style equality and treat the inherited TreeClass.__hash__ as disabled.

Setting eq_default=False aligns the typing metadata with the existing runtime behavior and preserves the inferred hashability of TreeClass subclasses.

Validation

  • NumPy backend: 229 passed, 11 skipped
  • ty 0.0.69 minimal reproduction: fails before this change and passes afterward

Evidence

FDTDX pre-commit failure with ty 0.0.69 reporting a Hashable incompatibility

autoinit only synthesizes __init__, so eq_default must be false to preserve TreeClass's inherited hashability in static analysis.
@yspkm

yspkm commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Added two small CI compatibility follow-ups: replaced the removed jax.tree_map usage in the docs and pinned JAX 0.4.13 only for Python 3.8. All JAX-backend tests pass locally on Python 3.8 through 3.11.

@yspkm

yspkm commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

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!

@ASEM000

ASEM000 commented Aug 12, 2026

Copy link
Copy Markdown
Owner

I will take a look asap.

@ASEM000

ASEM000 commented Aug 12, 2026

Copy link
Copy Markdown
Owner

looks fine to me.

@ASEM000

ASEM000 commented Aug 12, 2026

Copy link
Copy Markdown
Owner

can you bump up the version to 11.1 @yspkm and add a changelog entry?

@yspkm

yspkm commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

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.

@yspkm
yspkm force-pushed the fix/autoinit-hashable-typing branch from d6e49cd to 832e5ef Compare August 12, 2026 16:34
@yspkm

yspkm commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

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.

Hello @ASEM000, version bumped to 0.11.1 with the changelog entry added. All checks are green now. Thanks!

@ASEM000
ASEM000 merged commit 297c6af into ASEM000:main Aug 17, 2026
18 checks passed
@ASEM000

ASEM000 commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Merged @yspkm Thanks. Will publish tomorrow

@yspkm

yspkm commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Merged @yspkm Thanks. Will publish tomorrow

Thank you for merging this!

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