Skip to content

Conversation

@asnare
Copy link
Contributor

@asnare asnare commented Oct 24, 2024

Changes

This PR cherry-picks some changes from #3039 that updated the HistoryEncoder to work correctly with dataclasses that are declared with __future__.__annotations__ in effect.

When this annotation is in effect, python converts all type-hints during import/declaration into strings and then performs deferred resolution at a later stage. (This is why forward references work.) Unfortunately the dataclass mechanism captures field types prior to deferred resolution. This PR ensures that our type checking works anyway.

Linked issues

Cherry-picks from #3039.

Tests

  • updated unit tests

…dition to the normal class-based ones.

This is needed for correct functioning if a dataclass is declared in a __future__.__annotations__ context: here python converts all type hints to strings (at which point the dataclass metaclass captures them) prior to deferred resolution.
@asnare asnare added bug internal this pull request won't appear in release notes labels Oct 24, 2024
@asnare asnare self-assigned this Oct 24, 2024
@asnare asnare requested a review from a team as a code owner October 24, 2024 13:18
@github-actions
Copy link

✅ 6/6 passed, 15m15s total

Running from acceptance #7025

Copy link
Collaborator

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nfx nfx merged commit ece2a97 into main Oct 24, 2024
7 checks passed
@nfx nfx deleted the historical-encoder-str-annotations branch October 24, 2024 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal this pull request won't appear in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants