Last active
April 26, 2019 12:51
-
-
Save erickpeirson/b781bc1ce3418cfcfcfebdf689203ddf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JSONSchemaPlugin(Plugin): | |
"""Provides support for the JSON Schema as TypedDict.""" | |
# I put the placeholder class in a package called `jsonschema_typed`. | |
JSONSchema = 'jsonschema_typed.types.JSONSchema' | |
def get_type_analyze_hook(self, fullname: str) -> Optional[Callable]: | |
"""Produce an analyzer callback if a JSONSchema annotation is found.""" | |
if fullname == self.JSONSchema: | |
def callback(ctx: AnalyzeTypeContext) -> TypedDictType: | |
"""Generate annotations from a JSON Schema.""" | |
... # Here is where we need to generate the TypedDictType. | |
return callback |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment