浏览代码

fix version in pyproject and ruff version check (#4690)

* fix version in pyproject and ruff version check

* relock deps

* relax some strict values
Thomas Brandého 3 月之前
父节点
当前提交
9e36efbd21

文件差异内容过多而无法显示
+ 217 - 1
poetry.lock


+ 2 - 2
pyproject.toml

@@ -18,7 +18,7 @@ keywords = ["web", "framework"]
 classifiers = ["Development Status :: 4 - Beta"]
 
 [tool.poetry.dependencies]
-python = "^3.10"
+python = ">=3.10, <4.0"
 fastapi = ">=0.96.0,!=0.111.0,!=0.111.1"
 gunicorn = ">=20.1.0,<24.0"
 jinja2 = ">=3.1.2,<4.0"
@@ -82,7 +82,7 @@ build-backend = "poetry.core.masonry.api"
 [tool.pyright]
 
 [tool.ruff]
-target-version = "py39"
+target-version = "py310"
 output-format = "concise"
 lint.isort.split-on-trailing-comma = false
 lint.select = ["B", "C4", "D", "E", "ERA", "F", "FURB", "I", "N", "PERF", "PTH", "RUF", "SIM", "T", "TRY", "W"]

+ 6 - 2
reflex/app.py

@@ -672,7 +672,10 @@ class App(MiddlewareMixin, LifespanMixin):
         for route in self._pages:
             replaced_route = replace_brackets_with_keywords(route)
             for rw, r, nr in zip(
-                replaced_route.split("/"), route.split("/"), new_route.split("/")
+                replaced_route.split("/"),
+                route.split("/"),
+                new_route.split("/"),
+                strict=False,
             ):
                 if rw in segments and r != nr:
                     # If the slugs in the segments of both routes are not the same, then the route is invalid
@@ -1039,7 +1042,7 @@ class App(MiddlewareMixin, LifespanMixin):
                 max_workers=environment.REFLEX_COMPILE_THREADS.get() or None
             )
 
-        for route, component in zip(self._pages, page_components):
+        for route, component in zip(self._pages, page_components, strict=True):
             ExecutorSafeFunctions.COMPONENTS[route] = component
 
         ExecutorSafeFunctions.STATE = self._state
@@ -1236,6 +1239,7 @@ class App(MiddlewareMixin, LifespanMixin):
                 frontend_arg_spec,
                 backend_arg_spec,
             ],
+            strict=True,
         ):
             if hasattr(handler_fn, "__name__"):
                 _fn_name = handler_fn.__name__

+ 3 - 1
reflex/components/core/breakpoints.py

@@ -82,7 +82,9 @@ class Breakpoints(Dict[K, V]):
             return Breakpoints(
                 {
                     k: v
-                    for k, v in zip(["initial", *breakpoint_names], thresholds)
+                    for k, v in zip(
+                        ["initial", *breakpoint_names], thresholds, strict=True
+                    )
                     if v is not None
                 }
             )

+ 2 - 2
reflex/event.py

@@ -243,7 +243,7 @@ class EventHandler(EventActionsMixin):
                 raise EventHandlerTypeError(
                     f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}."
                 ) from e
-        payload = tuple(zip(fn_args, values))
+        payload = tuple(zip(fn_args, values, strict=False))
 
         # Return the event spec.
         return EventSpec(
@@ -337,7 +337,7 @@ class EventSpec(EventActionsMixin):
             raise EventHandlerTypeError(
                 f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}."
             ) from e
-        new_payload = tuple(zip(fn_args, values))
+        new_payload = tuple(zip(fn_args, values, strict=False))
         return self.with_args(self.args + new_payload)
 
 

+ 1 - 0
reflex/state.py

@@ -1434,6 +1434,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
         for part1, part2 in zip(
             cls.get_full_name().split("."),
             other.get_full_name().split("."),
+            strict=True,
         ):
             if part1 != part2:
                 break

+ 7 - 3
reflex/utils/types.py

@@ -605,7 +605,9 @@ def _isinstance(obj: Any, cls: GenericType, nested: bool = False) -> bool:
             return (
                 isinstance(obj, tuple)
                 and len(obj) == len(args)
-                and all(_isinstance(item, arg) for item, arg in zip(obj, args))
+                and all(
+                    _isinstance(item, arg) for item, arg in zip(obj, args, strict=True)
+                )
             )
         if origin in (dict, Breakpoints):
             return isinstance(obj, dict) and all(
@@ -808,7 +810,7 @@ def validate_parameter_literals(func):
         annotations = {param[0]: param[1].annotation for param in func_params}
 
         # validate args
-        for param, arg in zip(annotations, args):
+        for param, arg in zip(annotations, args, strict=False):
             if annotations[param] is inspect.Parameter.empty:
                 continue
             validate_literal(param, arg, annotations[param], func.__name__)
@@ -906,6 +908,8 @@ def typehint_issubclass(possible_subclass: Any, possible_superclass: Any) -> boo
     # It also ignores when the length of the arguments is different
     return all(
         typehint_issubclass(provided_arg, accepted_arg)
-        for provided_arg, accepted_arg in zip(provided_args, accepted_args)
+        for provided_arg, accepted_arg in zip(
+            provided_args, accepted_args, strict=False
+        )
         if accepted_arg is not Any
     )

+ 1 - 1
reflex/vars/base.py

@@ -2721,7 +2721,7 @@ def generic_type_to_actual_type_map(
     # call recursively for nested generic types and merge the results
     return {
         k: v
-        for generic_arg, actual_arg in zip(generic_args, actual_args)
+        for generic_arg, actual_arg in zip(generic_args, actual_args, strict=True)
         for k, v in generic_type_to_actual_type_map(generic_arg, actual_arg).items()
     }
 

+ 1 - 1
tests/units/compiler/test_compiler.py

@@ -100,7 +100,7 @@ def test_compile_imports(import_dict: ParsedImportDict, test_dicts: List[dict]):
         test_dicts: The expected output.
     """
     imports = utils.compile_imports(import_dict)
-    for import_dict, test_dict in zip(imports, test_dicts):
+    for import_dict, test_dict in zip(imports, test_dicts, strict=True):
         assert import_dict["lib"] == test_dict["lib"]
         assert import_dict["default"] == test_dict["default"]
         assert sorted(import_dict["rest"]) == test_dict["rest"]  # type: ignore

+ 2 - 0
tests/units/components/test_component.py

@@ -1446,6 +1446,7 @@ def test_get_vars(component, exp_vars):
     for comp_var, exp_var in zip(
         comp_vars,
         sorted(exp_vars, key=lambda v: v._js_expr),
+        strict=True,
     ):
         assert comp_var.equals(exp_var)
 
@@ -1827,6 +1828,7 @@ def test_custom_component_declare_event_handlers_in_fields():
         for v1, v2 in zip(
             parse_args_spec(test_triggers[trigger_name]),
             parse_args_spec(custom_triggers[trigger_name]),
+            strict=True,
         ):
             assert v1.equals(v2)
 

+ 3 - 0
tests/units/test_var.py

@@ -188,6 +188,7 @@ def ChildWithRuntimeOnlyVar(StateWithRuntimeOnlyVar):
             "state.local",
             "local2",
         ],
+        strict=True,
     ),
 )
 def test_full_name(prop, expected):
@@ -205,6 +206,7 @@ def test_full_name(prop, expected):
     zip(
         test_vars,
         ["prop1", "key", "state.value", "state.local", "local2"],
+        strict=True,
     ),
 )
 def test_str(prop, expected):
@@ -251,6 +253,7 @@ def test_default_value(prop: Var, expected):
             "state.set_local",
             "set_local2",
         ],
+        strict=True,
     ),
 )
 def test_get_setter(prop: Var, expected):

部分文件因为文件数量过多而无法显示