fix(type_checking): make sure forwardrefs blank pass type checking
This commit is contained in:
@@ -5,6 +5,7 @@ from typing import (
|
||||
Any,
|
||||
ClassVar,
|
||||
Dict,
|
||||
ForwardRef,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
@@ -217,6 +218,9 @@ def _validate_type(t: Optional[type], value: Any) -> Tuple[bool, Any]:
|
||||
return True, t(value)
|
||||
|
||||
if getattr(t, "__module__", None) == "typing":
|
||||
if isinstance(t, ForwardRef):
|
||||
return True, value
|
||||
|
||||
origin = getattr(t, "__origin__")
|
||||
# below is what in nicer for >= py38
|
||||
# origin = get_origin(t)
|
||||
|
||||
@@ -106,6 +106,7 @@ fake_bases = [FakeBase("foo"), FakeBase("bar")]
|
||||
True,
|
||||
fake_bases,
|
||||
),
|
||||
(List["int"], [2, 3, 4], True, [2, 3, 4])
|
||||
],
|
||||
)
|
||||
def test_validate_type(
|
||||
|
||||
Reference in New Issue
Block a user