fix type checks
This commit is contained in:
parent
de6bf175e2
commit
2ee8bc2f1a
|
@ -10,7 +10,7 @@ def check_type(attr_name: str, value: typing.Any, typeinfo: type) -> None:
|
||||||
|
|
||||||
- Union
|
- Union
|
||||||
- Tuple
|
- Tuple
|
||||||
- TextIO
|
- IO
|
||||||
"""
|
"""
|
||||||
# If we realize that we need to extend this list substantially, it may make sense
|
# If we realize that we need to extend this list substantially, it may make sense
|
||||||
# to use typeguard for this, but right now it's not worth the hassle for 16 lines of code.
|
# to use typeguard for this, but right now it's not worth the hassle for 16 lines of code.
|
||||||
|
@ -37,7 +37,7 @@ def check_type(attr_name: str, value: typing.Any, typeinfo: type) -> None:
|
||||||
for i, (x, T) in enumerate(zip(value, typeinfo.__tuple_params__)):
|
for i, (x, T) in enumerate(zip(value, typeinfo.__tuple_params__)):
|
||||||
check_type("{}[{}]".format(attr_name, i), x, T)
|
check_type("{}[{}]".format(attr_name, i), x, T)
|
||||||
return
|
return
|
||||||
if typeinfo == typing.TextIO:
|
if issubclass(typeinfo, typing.IO):
|
||||||
if hasattr(value, "read"):
|
if hasattr(value, "read"):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue