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 arbitrarily nested NewType/ Annotated types #272

Merged
merged 2 commits into from Jan 21, 2023
Merged

Support arbitrarily nested NewType/ Annotated types #272

merged 2 commits into from Jan 21, 2023

Conversation

MaksimZayats
Copy link
Contributor

Probably fixes #271

MaksimZayats and others added 2 commits January 19, 2023 17:43
This adds support for nesting `Annotated`/`NewType` wrappers in any
combination. Previously you could only nest:

- `Annotated[Annotated[...], ...]` (the `Annotated` constructor automatically
  flattens this, no need for `msgspec` to handle this case.
- `Annotated[NewType(...), ...]`

It also refactors the type processing code in `_core.c` to be a little
cleaner (still not "clean", Python type annotations aren't the easiest
objects to consume).
@jcrist jcrist changed the title Fix json.schema of NewType Support arbitrarily nested NewType/ Annotated types Jan 21, 2023
@jcrist
Copy link
Owner

jcrist commented Jan 21, 2023

Thanks for this PR! I've fixed up the remaining issues. Merging. I suspect it will be a few weeks before the next release. In the meantime you can use the workaround I posted in the corresponding issue, or install from github:

$ pip install git+https://github.com/jcrist/msgspec.git

@jcrist jcrist merged commit 058e860 into jcrist:main Jan 21, 2023
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.

NewType wrapping an Annotated with constraints is unsupported
2 participants