FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support integer Struct tags by jcrist · Pull Request #135 · msgspec/msgspec · GitHub

Support integer Struct tags - #135

Merged
jcrist merged 1 commit into
mainfrom
struct-int-tags
Jul 1, 2022
Merged

Support integer Struct tags#135
jcrist merged 1 commit into
mainfrom
struct-int-tags

Conversation

jcrist commented Jul 1, 2022

Copy link
Copy Markdown
Member

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 mentioned this pull request Jul 1, 2022
jcrist merged commit 0e83653 into main Jul 1, 2022
jcrist deleted the struct-int-tags branch July 1, 2022 21:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL