remove 3.11 special casing

This commit is contained in:
Khaleel Al-Adhami 2024-10-11 11:43:35 -07:00
parent 3a79c89799
commit 933b75816f
2 changed files with 8 additions and 3 deletions

View File

@ -195,8 +195,6 @@ def unionize(*args: GenericType) -> Type:
return Any return Any
if len(args) == 1: if len(args) == 1:
return args[0] return args[0]
if sys.version_info >= (3, 11):
return Union[*args] # type: ignore
# We are bisecting the args list here to avoid hitting the recursion limit # We are bisecting the args list here to avoid hitting the recursion limit
# In Python versions >= 3.11, we can simply do `return Union[*args]` # In Python versions >= 3.11, we can simply do `return Union[*args]`
midpoint = len(args) // 2 midpoint = len(args) // 2

View File

@ -399,11 +399,15 @@ def test_list_tuple_contains(var, expected):
class Foo(rx.Base): class Foo(rx.Base):
"""Foo class."""
bar: int bar: int
baz: str baz: str
class Bar(rx.Base): class Bar(rx.Base):
"""Bar class."""
bar: str bar: str
baz: str baz: str
foo: int foo: int
@ -416,7 +420,10 @@ class Bar(rx.Base):
(Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type(), Union[Foo, Bar]), (Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type(), Union[Foo, Bar]),
(Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type().bar, Union[int, str]), (Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type().bar, Union[int, str]),
(Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type().baz, str), (Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type().baz, str),
(Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type().foo, Union[int, None]), (
Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type().foo,
Union[int, None],
),
], ],
) )
def test_var_types(var, var_type): def test_var_types(var, var_type):