move union below
This commit is contained in:
parent
56487cd4be
commit
374cd14862
@ -191,7 +191,7 @@ def satisfies_type_hint(obj: Any, type_hint: Any) -> bool:
|
|||||||
Returns:
|
Returns:
|
||||||
Whether the object satisfies the type hint.
|
Whether the object satisfies the type hint.
|
||||||
"""
|
"""
|
||||||
return types._isinstance(obj, type_hint, nested=0)
|
return types._isinstance(obj, type_hint, nested=1)
|
||||||
|
|
||||||
|
|
||||||
class Component(BaseComponent, ABC):
|
class Component(BaseComponent, ABC):
|
||||||
|
@ -567,9 +567,6 @@ def _isinstance(obj: Any, cls: GenericType, nested: int = 0) -> bool:
|
|||||||
|
|
||||||
from reflex.vars import LiteralVar, Var
|
from reflex.vars import LiteralVar, Var
|
||||||
|
|
||||||
if cls and is_union(cls):
|
|
||||||
return any(_isinstance(obj, arg, nested=nested) for arg in get_args(cls))
|
|
||||||
|
|
||||||
if cls is Var:
|
if cls is Var:
|
||||||
return isinstance(obj, Var)
|
return isinstance(obj, Var)
|
||||||
if isinstance(obj, LiteralVar):
|
if isinstance(obj, LiteralVar):
|
||||||
@ -580,6 +577,9 @@ def _isinstance(obj: Any, cls: GenericType, nested: int = 0) -> bool:
|
|||||||
if cls is None or cls is type(None):
|
if cls is None or cls is type(None):
|
||||||
return obj is None
|
return obj is None
|
||||||
|
|
||||||
|
if cls and is_union(cls):
|
||||||
|
return any(_isinstance(obj, arg, nested=nested) for arg in get_args(cls))
|
||||||
|
|
||||||
if is_literal(cls):
|
if is_literal(cls):
|
||||||
return obj in get_args(cls)
|
return obj in get_args(cls)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user