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.
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
Schematypes usingTypedDict. 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
exclusiveMaximumas eitherboolorint | floatdepending on the schema draft version.