Skip to content

Support arbitrarily nested NewType/ Annotated types - #272

Merged
jcrist merged 2 commits into
msgspec:mainfrom
maksimzayats:main
Jan 21, 2023
Merged

jcrist merged 2 commits into
msgspec:mainfrom
maksimzayats:main

Conversation

@maksimzayats

Copy link
Copy Markdown
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

jcrist commented Jan 21, 2023

Copy link
Copy Markdown
Member

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 msgspec: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