resolve merge mistakes
This commit is contained in:
parent
68b8c12127
commit
1f9fbd88de
@ -7,7 +7,7 @@ from typing import Any, overload
|
|||||||
from reflex.components.base.fragment import Fragment
|
from reflex.components.base.fragment import Fragment
|
||||||
from reflex.components.component import BaseComponent, Component
|
from reflex.components.component import BaseComponent, Component
|
||||||
from reflex.style import LIGHT_COLOR_MODE, resolved_color_mode
|
from reflex.style import LIGHT_COLOR_MODE, resolved_color_mode
|
||||||
from reflex.utils.types import infallible_issubclass
|
from reflex.utils.types import safe_issubclass
|
||||||
from reflex.vars.base import LiteralVar, ReflexCallable, Var
|
from reflex.vars.base import LiteralVar, ReflexCallable, Var
|
||||||
from reflex.vars.function import ArgsFunctionOperation
|
from reflex.vars.function import ArgsFunctionOperation
|
||||||
from reflex.vars.number import ternary_operation
|
from reflex.vars.number import ternary_operation
|
||||||
@ -40,7 +40,7 @@ def cond(condition: Any, c1: Any, c2: Any = None) -> Component | Var:
|
|||||||
|
|
||||||
# If the first component is a component, create a Fragment if the second component is not set.
|
# If the first component is a component, create a Fragment if the second component is not set.
|
||||||
if isinstance(c1, BaseComponent) or (
|
if isinstance(c1, BaseComponent) or (
|
||||||
isinstance(c1, Var) and infallible_issubclass(c1._var_type, BaseComponent)
|
isinstance(c1, Var) and safe_issubclass(c1._var_type, BaseComponent)
|
||||||
):
|
):
|
||||||
c2 = c2 if c2 is not None else Fragment.create()
|
c2 = c2 if c2 is not None else Fragment.create()
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ from typing_extensions import (
|
|||||||
TypeVar,
|
TypeVar,
|
||||||
TypeVarTuple,
|
TypeVarTuple,
|
||||||
Unpack,
|
Unpack,
|
||||||
deprecated,
|
|
||||||
get_args,
|
get_args,
|
||||||
get_origin,
|
get_origin,
|
||||||
)
|
)
|
||||||
@ -803,24 +802,6 @@ def redirect(
|
|||||||
path: str | Var[str],
|
path: str | Var[str],
|
||||||
is_external: bool = False,
|
is_external: bool = False,
|
||||||
replace: bool = False,
|
replace: bool = False,
|
||||||
) -> EventSpec: ...
|
|
||||||
|
|
||||||
|
|
||||||
@overload
|
|
||||||
@deprecated("`external` is deprecated use `is_external` instead")
|
|
||||||
def redirect(
|
|
||||||
path: str | Var[str],
|
|
||||||
is_external: Optional[bool] = None,
|
|
||||||
replace: bool = False,
|
|
||||||
external: Optional[bool] = None,
|
|
||||||
) -> EventSpec: ...
|
|
||||||
|
|
||||||
|
|
||||||
def redirect(
|
|
||||||
path: str | Var[str],
|
|
||||||
is_external: Optional[bool] = None,
|
|
||||||
replace: bool = False,
|
|
||||||
external: Optional[bool] = None,
|
|
||||||
) -> EventSpec:
|
) -> EventSpec:
|
||||||
"""Redirect to a new path.
|
"""Redirect to a new path.
|
||||||
|
|
||||||
|
@ -842,25 +842,6 @@ StateIterBases = get_base_class(StateIterVar)
|
|||||||
def safe_issubclass(cls: Any, class_or_tuple: Any, /) -> bool:
|
def safe_issubclass(cls: Any, class_or_tuple: Any, /) -> bool:
|
||||||
"""Check if a class is a subclass of another class or a tuple of classes.
|
"""Check if a class is a subclass of another class or a tuple of classes.
|
||||||
|
|
||||||
Args:
|
|
||||||
cls: The class to check.
|
|
||||||
class_or_tuple: The class or tuple of classes to check against.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Whether the class is a subclass of the other class or tuple of classes.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
TypeError: If the arguments are invalid.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
return issubclass(cls, class_or_tuple)
|
|
||||||
except TypeError as e:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def infallible_issubclass(cls: Any, class_or_tuple: Any, /) -> bool:
|
|
||||||
"""Check if a class is a subclass of another class or a tuple of classes.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
cls: The class to check.
|
cls: The class to check.
|
||||||
class_or_tuple: The class or tuple of classes to check against.
|
class_or_tuple: The class or tuple of classes to check against.
|
||||||
@ -981,7 +962,7 @@ def typehint_issubclass(possible_subclass: Any, possible_superclass: Any) -> boo
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# Check if the origin of both types is the same (e.g., list for List[int])
|
# Check if the origin of both types is the same (e.g., list for List[int])
|
||||||
if not infallible_issubclass(
|
if not safe_issubclass(
|
||||||
provided_type_origin or possible_subclass,
|
provided_type_origin or possible_subclass,
|
||||||
accepted_type_origin or possible_superclass,
|
accepted_type_origin or possible_superclass,
|
||||||
):
|
):
|
||||||
|
@ -74,9 +74,8 @@ from reflex.utils.types import (
|
|||||||
_isinstance,
|
_isinstance,
|
||||||
get_origin,
|
get_origin,
|
||||||
has_args,
|
has_args,
|
||||||
infallible_issubclass,
|
|
||||||
typehint_issubclass,
|
|
||||||
safe_issubclass,
|
safe_issubclass,
|
||||||
|
typehint_issubclass,
|
||||||
unionize,
|
unionize,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -764,7 +763,7 @@ class Var(Generic[VAR_TYPE]):
|
|||||||
for var_subclass in _var_subclasses[::-1]:
|
for var_subclass in _var_subclasses[::-1]:
|
||||||
if (
|
if (
|
||||||
var_subclass.python_types
|
var_subclass.python_types
|
||||||
and infallible_issubclass(fixed_output_type, var_subclass.python_types)
|
and safe_issubclass(fixed_output_type, var_subclass.python_types)
|
||||||
) or (
|
) or (
|
||||||
var_subclass.is_subclass and var_subclass.is_subclass(fixed_output_type)
|
var_subclass.is_subclass and var_subclass.is_subclass(fixed_output_type)
|
||||||
):
|
):
|
||||||
@ -863,7 +862,7 @@ class Var(Generic[VAR_TYPE]):
|
|||||||
for var_subclass in _var_subclasses:
|
for var_subclass in _var_subclasses:
|
||||||
if all(
|
if all(
|
||||||
(
|
(
|
||||||
infallible_issubclass(t, var_subclass.python_types)
|
safe_issubclass(t, var_subclass.python_types)
|
||||||
or (var_subclass.is_subclass and var_subclass.is_subclass(t))
|
or (var_subclass.is_subclass and var_subclass.is_subclass(t))
|
||||||
)
|
)
|
||||||
for t in inner_types
|
for t in inner_types
|
||||||
@ -886,7 +885,7 @@ class Var(Generic[VAR_TYPE]):
|
|||||||
return self.to(None)
|
return self.to(None)
|
||||||
|
|
||||||
for var_subclass in _var_subclasses[::-1]:
|
for var_subclass in _var_subclasses[::-1]:
|
||||||
if infallible_issubclass(fixed_type, var_subclass.python_types) or (
|
if safe_issubclass(fixed_type, var_subclass.python_types) or (
|
||||||
var_subclass.is_subclass and var_subclass.is_subclass(fixed_type)
|
var_subclass.is_subclass and var_subclass.is_subclass(fixed_type)
|
||||||
):
|
):
|
||||||
return self.to(var_subclass.var_subclass, self._var_type)
|
return self.to(var_subclass.var_subclass, self._var_type)
|
||||||
|
@ -143,7 +143,7 @@ class ObjectVar(Var[OBJECT_TYPE], python_types=Mapping):
|
|||||||
|
|
||||||
# NoReturn is used here to catch when key value is Any
|
# NoReturn is used here to catch when key value is Any
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(
|
def __getitem__( # pyright: ignore [reportOverlappingOverload]
|
||||||
self: ObjectVar[Mapping[Any, NoReturn]],
|
self: ObjectVar[Mapping[Any, NoReturn]],
|
||||||
key: Var | Any,
|
key: Var | Any,
|
||||||
) -> Var: ...
|
) -> Var: ...
|
||||||
|
Loading…
Reference in New Issue
Block a user