Correct Python 3.7 compatibility hack
mypy complained about the signature of conditional def of get_args not matching the one from typing module, so I made it match, but apparently hadn't actually tested it with Python 3.7. It was just the return type hint, but it sill needs to parse at run time. Also, fix up a few other (non-error) gripes from pylint.
This commit is contained in:
parent
5ff207ed8c
commit
1167742f75
1 changed files with 4 additions and 4 deletions
|
@ -352,10 +352,10 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Python 3.7 does not have TypedDict, so fake it so the run time still
|
# Python 3.7 does not have TypedDict, so fake it so the run time still
|
||||||
# works, even though static type checker probably will not.
|
# works, even though static type checker probably will not.
|
||||||
def TypedDict(name, types):
|
def TypedDict(name, types): # pylint: disable=invalid-name
|
||||||
return type(name, (dict,), {"__annotations__": types})
|
return type(name, (dict,), {"__annotations__": types})
|
||||||
|
|
||||||
def get_args(tp: Any) -> tuple[Any, ...]:
|
def get_args(tp: Any) -> Tuple[Any, ...]:
|
||||||
return tp.__args__
|
return tp.__args__
|
||||||
|
|
||||||
|
|
||||||
|
@ -483,11 +483,11 @@ _FIELD_NAME_MAP = {
|
||||||
|
|
||||||
|
|
||||||
def _field_names(hint_type):
|
def _field_names(hint_type):
|
||||||
return list(_FIELD_NAME_MAP.get(key, key) for key in get_type_hints(hint_type).keys())
|
return list(_FIELD_NAME_MAP.get(key, key) for key in get_type_hints(hint_type))
|
||||||
|
|
||||||
|
|
||||||
def _field_names_bulk(hint_type):
|
def _field_names_bulk(hint_type):
|
||||||
return list(key + "[]" for key in get_type_hints(hint_type).keys())
|
return list(key + "[]" for key in get_type_hints(hint_type))
|
||||||
|
|
||||||
|
|
||||||
def _field_types(hint_type):
|
def _field_types(hint_type):
|
||||||
|
|
Loading…
Reference in a new issue