Skip to content

Commit 126a55e

Browse files
authored
remove some code no longer useful in 3.10+ (#5119)
1 parent 7a5e791 commit 126a55e

2 files changed

Lines changed: 17 additions & 36 deletions

File tree

reflex/utils/types.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import dataclasses
66
import inspect
7-
import sys
87
import types
98
from functools import cached_property, lru_cache, wraps
109
from types import GenericAlias
@@ -414,10 +413,7 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None
414413
)
415414
elif isinstance(cls, type):
416415
# Bare class
417-
if sys.version_info >= (3, 10):
418-
exceptions = NameError
419-
else:
420-
exceptions = (NameError, TypeError)
416+
exceptions = NameError
421417
try:
422418
hints = get_type_hints(cls)
423419
if name in hints:
@@ -1008,14 +1004,12 @@ def typehint_issubclass(
10081004
for arg in args
10091005
)
10101006

1011-
# Remove this check when Python 3.10 is the minimum supported version
1012-
if hasattr(types, "UnionType"):
1013-
provided_type_origin = (
1014-
Union if provided_type_origin is types.UnionType else provided_type_origin
1015-
)
1016-
accepted_type_origin = (
1017-
Union if accepted_type_origin is types.UnionType else accepted_type_origin
1018-
)
1007+
provided_type_origin = (
1008+
Union if provided_type_origin is types.UnionType else provided_type_origin
1009+
)
1010+
accepted_type_origin = (
1011+
Union if accepted_type_origin is types.UnionType else accepted_type_origin
1012+
)
10191013

10201014
# Get type arguments (e.g., [float, int] for dict[float, int])
10211015
provided_args = get_args(possible_subclass)

reflex/vars/function.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import annotations
44

55
import dataclasses
6-
import sys
76
from typing import (
87
Any,
98
Callable,
@@ -470,25 +469,13 @@ def create(
470469
)
471470

472471

473-
if python_version := sys.version_info[:2] >= (3, 10):
474-
JSON_STRINGIFY = FunctionStringVar.create(
475-
"JSON.stringify", _var_type=ReflexCallable[[Any], str]
476-
)
477-
ARRAY_ISARRAY = FunctionStringVar.create(
478-
"Array.isArray", _var_type=ReflexCallable[[Any], bool]
479-
)
480-
PROTOTYPE_TO_STRING = FunctionStringVar.create(
481-
"((__to_string) => __to_string.toString())",
482-
_var_type=ReflexCallable[[Any], str],
483-
)
484-
else:
485-
JSON_STRINGIFY = FunctionStringVar.create(
486-
"JSON.stringify", _var_type=ReflexCallable[Any, str]
487-
)
488-
ARRAY_ISARRAY = FunctionStringVar.create(
489-
"Array.isArray", _var_type=ReflexCallable[Any, bool]
490-
)
491-
PROTOTYPE_TO_STRING = FunctionStringVar.create(
492-
"((__to_string) => __to_string.toString())",
493-
_var_type=ReflexCallable[Any, str],
494-
)
472+
JSON_STRINGIFY = FunctionStringVar.create(
473+
"JSON.stringify", _var_type=ReflexCallable[[Any], str]
474+
)
475+
ARRAY_ISARRAY = FunctionStringVar.create(
476+
"Array.isArray", _var_type=ReflexCallable[[Any], bool]
477+
)
478+
PROTOTYPE_TO_STRING = FunctionStringVar.create(
479+
"((__to_string) => __to_string.toString())",
480+
_var_type=ReflexCallable[[Any], str],
481+
)

0 commit comments

Comments
 (0)