fix(type_checking): make sure forwardrefs blank pass type checking

This commit is contained in:
Gergő Jedlicska
2023-02-15 19:20:45 +01:00
parent 8352bb5c9a
commit ea7baf8eb5
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -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)
+1
View File
@@ -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(