Last active
October 3, 2020 09:37
-
-
Save catb0t/bd82f7815b7e95b5dd3c3ad294f3cbbf to your computer and use it in GitHub Desktop.
Strict no-Any MyPy JSON type
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
# modified from Original source: https://github.com/python/mypy/issues/731#issuecomment-539905783 | |
from typing import Union, Dict, List | |
JSONPrimitive = Union[str, int, bool, None] | |
JSONType = Union[JSONPrimitive, 'JSONList', 'JSONDict'] | |
# work around mypy#731: no recursive structural types yet | |
class JSONList(List[JSONType]): | |
pass | |
class JSONDict(Dict[str, JSONType]): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment