hypothesis-jsonschema
hypothesis-jsonschema copied to clipboard
Idea: detailed version-specific type annotations for `Schema`
I recently saw https://github.com/python/typing/issues/182#issuecomment-899624078 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 https://github.com/Julian/jsonschema/issues/766 and https://github.com/Julian/jsonschema/issues/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.
Mypy 0.990 has native support for recursive types, so this is now possible without hacks.