Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support integer Struct tags #135

Merged
merged 1 commit into from
Jul 1, 2022
Merged

Support integer Struct tags #135

merged 1 commit into from
Jul 1, 2022

Conversation

jcrist
Copy link
Owner

@jcrist jcrist commented Jul 1, 2022

Previously tagged unions only supported str tag values. We now also
support int tag values, with a few caveats:

  • A single Union of Struct types cannot mix both int and str tag
    types.
  • Integer tag values currently only support values that fit in an
    int64 (-2**63 <= tag <= 2**63 - 1). This restriction has also been added
    to IntEnum and integer Literal types (previously these supported up
    to a uint64). This restriction makes the implementation easier, but
    can be removed if needed in the future. For now a NotImplementedError
    is raised if the user attempts to use out-of-range integer values,
    pointing them to raise an issue on GitHub if they need the feature.

Fixes #134.

Previously tagged unions only supported `str` tag values. We now also
support `int` tag values, with a few caveats:

- A single `Union` of `Struct` types cannot mix both `int` and `str` tag
types.
- Integer `tag` values currently only support values that fit in an
int64 (-2**63 <= tag <= 2**63 - 1). This restriction has also been added
to `IntEnum` and integer `Literal` types (previously these supported up
to a `uint64`). This restriction makes the implementation easier, but
can be removed if needed in the future. For now a `NotImplementedError`
is raised if the user attempts to use out-of-range integer values,
pointing them to raise an issue on GitHub if they need the feature.
@jcrist jcrist mentioned this pull request Jul 1, 2022
@jcrist jcrist merged commit 0e83653 into main Jul 1, 2022
@jcrist jcrist deleted the struct-int-tags branch July 1, 2022 21:38
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.

Non-string tag values
1 participant