소스 검색

remove some code no longer useful in 3.10+ (#5119)

Thomas Brandého 1 개월 전
부모
커밋
126a55efbc
2개의 변경된 파일17개의 추가작업 그리고 36개의 파일을 삭제
  1. 7 13
      reflex/utils/types.py
  2. 10 23
      reflex/vars/function.py

+ 7 - 13
reflex/utils/types.py

@@ -4,7 +4,6 @@ from __future__ import annotations
 
 import dataclasses
 import inspect
-import sys
 import types
 from functools import cached_property, lru_cache, wraps
 from types import GenericAlias
@@ -414,10 +413,7 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None
         )
     elif isinstance(cls, type):
         # Bare class
-        if sys.version_info >= (3, 10):
-            exceptions = NameError
-        else:
-            exceptions = (NameError, TypeError)
+        exceptions = NameError
         try:
             hints = get_type_hints(cls)
             if name in hints:
@@ -1008,14 +1004,12 @@ def typehint_issubclass(
             for arg in args
         )
 
-    # Remove this check when Python 3.10 is the minimum supported version
-    if hasattr(types, "UnionType"):
-        provided_type_origin = (
-            Union if provided_type_origin is types.UnionType else provided_type_origin
-        )
-        accepted_type_origin = (
-            Union if accepted_type_origin is types.UnionType else accepted_type_origin
-        )
+    provided_type_origin = (
+        Union if provided_type_origin is types.UnionType else provided_type_origin
+    )
+    accepted_type_origin = (
+        Union if accepted_type_origin is types.UnionType else accepted_type_origin
+    )
 
     # Get type arguments (e.g., [float, int] for dict[float, int])
     provided_args = get_args(possible_subclass)

+ 10 - 23
reflex/vars/function.py

@@ -3,7 +3,6 @@
 from __future__ import annotations
 
 import dataclasses
-import sys
 from typing import (
     Any,
     Callable,
@@ -470,25 +469,13 @@ class ArgsFunctionOperationBuilder(CachedVarOperation, BuilderFunctionVar):
         )
 
 
-if python_version := sys.version_info[:2] >= (3, 10):
-    JSON_STRINGIFY = FunctionStringVar.create(
-        "JSON.stringify", _var_type=ReflexCallable[[Any], str]
-    )
-    ARRAY_ISARRAY = FunctionStringVar.create(
-        "Array.isArray", _var_type=ReflexCallable[[Any], bool]
-    )
-    PROTOTYPE_TO_STRING = FunctionStringVar.create(
-        "((__to_string) => __to_string.toString())",
-        _var_type=ReflexCallable[[Any], str],
-    )
-else:
-    JSON_STRINGIFY = FunctionStringVar.create(
-        "JSON.stringify", _var_type=ReflexCallable[Any, str]
-    )
-    ARRAY_ISARRAY = FunctionStringVar.create(
-        "Array.isArray", _var_type=ReflexCallable[Any, bool]
-    )
-    PROTOTYPE_TO_STRING = FunctionStringVar.create(
-        "((__to_string) => __to_string.toString())",
-        _var_type=ReflexCallable[Any, str],
-    )
+JSON_STRINGIFY = FunctionStringVar.create(
+    "JSON.stringify", _var_type=ReflexCallable[[Any], str]
+)
+ARRAY_ISARRAY = FunctionStringVar.create(
+    "Array.isArray", _var_type=ReflexCallable[[Any], bool]
+)
+PROTOTYPE_TO_STRING = FunctionStringVar.create(
+    "((__to_string) => __to_string.toString())",
+    _var_type=ReflexCallable[[Any], str],
+)