def assert_json_type(value: JsonValue, expected_type: JsonCheckType) -> None:
def type_name(t: Union[JsonCheckType, Type[None]]) -> str:<EOL><INDENT>if t is None:<EOL><INDENT>return "<STR_LIT:None>"<EOL><DEDENT>if isinstance(t, JList):<EOL><INDENT>return "<STR_LIT:list>"<EOL><DEDENT>return t.__name__<EOL><DEDENT>if expected_type is None:<EOL><INDENT>if value is None:<EOL><INDENT>return<EOL><DEDENT><DEDENT>elif expected_type == float:<EOL><INDENT>if isinstance(value, float) or isinstance(value, int):<EOL><INDENT>return<EOL><DEDENT><DEDENT>elif expected_type in [str, int, bool, list, dict]:<EOL><INDENT>if isinstance(value, expected_type):  <EOL><INDENT>return<EOL><DEDENT><DEDENT>elif isinstance(expected_type, JList):<EOL><INDENT>if isinstance(value, list):<EOL><INDENT>for v in value:<EOL><INDENT>assert_json_type(v, expected_type.value_type)<EOL><DEDENT>return<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>raise TypeError("<STR_LIT>".format(<EOL>type_name(expected_type), type_name(type(value))))<EOL>
Check that a value has a certain JSON type.

    Raise TypeError if the type does not match.

    Supported types: str, int, float, bool, list, dict, and None.
    float will match any number, int will only match numbers without
    fractional part.

    The special type JList(x) will match a list value where each
    item is of type x:

    >>> assert_json_type([1, 2, 3], JList(int))