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.component import BaseComponent, Component
|
||||
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.function import ArgsFunctionOperation
|
||||
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 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()
|
||||
|
||||
|
@ -34,7 +34,6 @@ from typing_extensions import (
|
||||
TypeVar,
|
||||
TypeVarTuple,
|
||||
Unpack,
|
||||
deprecated,
|
||||
get_args,
|
||||
get_origin,
|
||||
)
|
||||
@ -803,24 +802,6 @@ def redirect(
|
||||
path: str | Var[str],
|
||||
is_external: 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:
|
||||
"""Redirect to a new path.
|
||||
|
||||
|
@ -842,25 +842,6 @@ StateIterBases = get_base_class(StateIterVar)
|
||||
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.
|
||||
|
||||
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:
|
||||
cls: The class to check.
|
||||
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
|
||||
|
||||
# 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,
|
||||
accepted_type_origin or possible_superclass,
|
||||
):
|
||||
|
@ -74,9 +74,8 @@ from reflex.utils.types import (
|
||||
_isinstance,
|
||||
get_origin,
|
||||
has_args,
|
||||
infallible_issubclass,
|
||||
typehint_issubclass,
|
||||
safe_issubclass,
|
||||
typehint_issubclass,
|
||||
unionize,
|
||||
)
|
||||
|
||||
@ -764,7 +763,7 @@ class Var(Generic[VAR_TYPE]):
|
||||
for var_subclass in _var_subclasses[::-1]:
|
||||
if (
|
||||
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 (
|
||||
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:
|
||||
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))
|
||||
)
|
||||
for t in inner_types
|
||||
@ -886,7 +885,7 @@ class Var(Generic[VAR_TYPE]):
|
||||
return self.to(None)
|
||||
|
||||
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)
|
||||
):
|
||||
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
|
||||
@overload
|
||||
def __getitem__(
|
||||
def __getitem__( # pyright: ignore [reportOverlappingOverload]
|
||||
self: ObjectVar[Mapping[Any, NoReturn]],
|
||||
key: Var | Any,
|
||||
) -> Var: ...
|
||||
|
Loading…
Reference in New Issue
Block a user