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

Idea: detailed version-specific type annotations for Schema #91

Open
Zac-HD opened this issue Oct 14, 2021 · 1 comment
Open

Idea: detailed version-specific type annotations for Schema #91

Zac-HD opened this issue Oct 14, 2021 · 1 comment

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Oct 14, 2021

I recently saw python/typing#182 (comment) proposing a nice trick for type-checking JSON data, and it occured to me that this could be extended to define version-specific Schema types using TypedDict. See also python-jsonschema/jsonschema#766 and python-jsonschema/jsonschema#778 - if we get a working implementation, this would probably be suitable for upstreaming.

For example, this would allow for static detection of exclusiveMaximum as either bool or int | float depending on the schema draft version.

@Zac-HD
Copy link
Member Author

Zac-HD commented Nov 14, 2022

Mypy 0.990 has native support for recursive types, so this is now possible without hacks.

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

No branches or pull requests

1 participant