瀏覽代碼

pyright checklist

Masen Furer 8 月之前
父節點
當前提交
19e10038b6
共有 6 個文件被更改,包括 22 次插入20 次删除
  1. 5 5
      poetry.lock
  2. 1 1
      pyproject.toml
  3. 6 7
      reflex/base.py
  4. 1 1
      reflex/config.py
  5. 6 4
      reflex/event.py
  6. 3 2
      reflex/utils/types.py

+ 5 - 5
poetry.lock

@@ -1,4 +1,4 @@
-# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
+# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
 
 
 [[package]]
 [[package]]
 name = "alembic"
 name = "alembic"
@@ -1842,13 +1842,13 @@ files = [
 
 
 [[package]]
 [[package]]
 name = "pyright"
 name = "pyright"
-version = "1.1.334"
+version = "1.1.378"
 description = "Command line wrapper for pyright"
 description = "Command line wrapper for pyright"
 optional = false
 optional = false
 python-versions = ">=3.7"
 python-versions = ">=3.7"
 files = [
 files = [
-    {file = "pyright-1.1.334-py3-none-any.whl", hash = "sha256:dcb13e8358e021189672c4d6ebcad192ab061e4c7225036973ec493183c6da68"},
-    {file = "pyright-1.1.334.tar.gz", hash = "sha256:3adaf10f1f4209575dc022f9c897f7ef024639b7ea5b3cbe49302147e6949cd4"},
+    {file = "pyright-1.1.378-py3-none-any.whl", hash = "sha256:8853776138b01bc284da07ac481235be7cc89d3176b073d2dba73636cb95be79"},
+    {file = "pyright-1.1.378.tar.gz", hash = "sha256:78a043be2876d12d0af101d667e92c7734f3ebb9db71dccc2c220e7e7eb89ca2"},
 ]
 ]
 
 
 [package.dependencies]
 [package.dependencies]
@@ -3179,4 +3179,4 @@ type = ["pytest-mypy"]
 [metadata]
 [metadata]
 lock-version = "2.0"
 lock-version = "2.0"
 python-versions = "^3.8"
 python-versions = "^3.8"
-content-hash = "c5d4fa9102c7fd39a6300628d22ca67cbf013e6d580eab43723b5b9ee02a57b8"
+content-hash = "9d77c059894e360c1bc0f5f12bcacab5cd6b86e3ceaf835ba55937218388446d"

+ 1 - 1
pyproject.toml

@@ -69,7 +69,7 @@ reflex-chakra = ">=0.6.0a"
 [tool.poetry.group.dev.dependencies]
 [tool.poetry.group.dev.dependencies]
 pytest = ">=7.1.2,<8.0"
 pytest = ">=7.1.2,<8.0"
 pytest-mock = ">=3.10.0,<4.0"
 pytest-mock = ">=3.10.0,<4.0"
-pyright = ">=1.1.229,<1.1.335"
+pyright = ">=1.1.229"
 darglint = ">=1.8.1,<2.0"
 darglint = ">=1.8.1,<2.0"
 toml = ">=0.10.2,<1.0"
 toml = ">=0.10.2,<1.0"
 pytest-asyncio = ">=0.20.1,<0.22.0" # https://github.com/pytest-dev/pytest-asyncio/issues/706
 pytest-asyncio = ">=0.20.1,<0.22.0" # https://github.com/pytest-dev/pytest-asyncio/issues/706

+ 6 - 7
reflex/base.py

@@ -3,17 +3,16 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
 import os
 import os
-from typing import TYPE_CHECKING, Any, List, Type
+from typing import Any, List, Type
 
 
 try:
 try:
     import pydantic.v1.main as pydantic_main
     import pydantic.v1.main as pydantic_main
     from pydantic.v1 import BaseModel
     from pydantic.v1 import BaseModel
     from pydantic.v1.fields import ModelField
     from pydantic.v1.fields import ModelField
 except ModuleNotFoundError:
 except ModuleNotFoundError:
-    if not TYPE_CHECKING:
-        import pydantic.main as pydantic_main
-        from pydantic import BaseModel
-        from pydantic.fields import ModelField  # type: ignore
+    import pydantic.main as pydantic_main
+    from pydantic import BaseModel
+    from pydantic.fields import ModelField  # type: ignore
 
 
 
 
 from reflex import constants
 from reflex import constants
@@ -48,7 +47,7 @@ def validate_field_name(bases: List[Type["BaseModel"]], field_name: str) -> None
 pydantic_main.validate_field_name = validate_field_name  # type: ignore
 pydantic_main.validate_field_name = validate_field_name  # type: ignore
 
 
 
 
-class Base(BaseModel):  # pyright: ignore [reportUnboundVariable]
+class Base(BaseModel):  # pyright: ignore [reportGeneralTypeIssues]
     """The base class subclassed by all Reflex classes.
     """The base class subclassed by all Reflex classes.
 
 
     This class wraps Pydantic and provides common methods such as
     This class wraps Pydantic and provides common methods such as
@@ -65,7 +64,7 @@ class Base(BaseModel):  # pyright: ignore [reportUnboundVariable]
         use_enum_values = True
         use_enum_values = True
         extra = "allow"
         extra = "allow"
 
 
-    def json(self) -> str:
+    def json(self) -> str:  # pyright: ignore [reportIncompatibleMethodOverride]
         """Convert the object to a json string.
         """Convert the object to a json string.
 
 
         Returns:
         Returns:

+ 1 - 1
reflex/config.py

@@ -149,7 +149,7 @@ class Config(Base):
     See the [configuration](https://reflex.dev/docs/getting-started/configuration/) docs for more info.
     See the [configuration](https://reflex.dev/docs/getting-started/configuration/) docs for more info.
     """
     """
 
 
-    class Config:
+    class Config:  # type: ignore
         """Pydantic config for the config."""
         """Pydantic config for the config."""
 
 
         validate_assignment = True
         validate_assignment = True

+ 6 - 4
reflex/event.py

@@ -144,7 +144,7 @@ class EventHandler(EventActionsMixin):
     # Empty string means this event handler is a server side event.
     # Empty string means this event handler is a server side event.
     state_full_name: str = ""
     state_full_name: str = ""
 
 
-    class Config:
+    class Config:  # type: ignore
         """The Pydantic config."""
         """The Pydantic config."""
 
 
         # Needed to allow serialization of Callable.
         # Needed to allow serialization of Callable.
@@ -229,7 +229,7 @@ class EventSpec(EventActionsMixin):
     # The arguments to pass to the function.
     # The arguments to pass to the function.
     args: Tuple[Tuple[Var, Var], ...] = ()
     args: Tuple[Tuple[Var, Var], ...] = ()
 
 
-    class Config:
+    class Config:  # type: ignore
         """The Pydantic config."""
         """The Pydantic config."""
 
 
         # Required to allow tuple fields.
         # Required to allow tuple fields.
@@ -363,7 +363,9 @@ class FileUpload(Base):
     on_upload_progress: Optional[Union[EventHandler, Callable]] = None
     on_upload_progress: Optional[Union[EventHandler, Callable]] = None
 
 
     @staticmethod
     @staticmethod
-    def on_upload_progress_args_spec(_prog: Dict[str, Union[int, float, bool]]):
+    def on_upload_progress_args_spec(
+        _prog: Var[Dict[str, Union[int, float, bool]]],
+    ) -> list[Var]:
         """Args spec for on_upload_progress event handler.
         """Args spec for on_upload_progress event handler.
 
 
         Returns:
         Returns:
@@ -463,7 +465,7 @@ def server_side(name: str, sig: inspect.Signature, **kwargs) -> EventSpec:
         return None
         return None
 
 
     fn.__qualname__ = name
     fn.__qualname__ = name
-    fn.__signature__ = sig
+    fn.__signature__ = sig  # pyright: ignore [reportFunctionMemberAccess]
     return EventSpec(
     return EventSpec(
         handler=EventHandler(fn=fn),
         handler=EventHandler(fn=fn),
         args=tuple(
         args=tuple(

+ 3 - 2
reflex/utils/types.py

@@ -95,8 +95,9 @@ PrimitiveType = Union[int, float, bool, str, list, dict, set, tuple]
 StateVar = Union[PrimitiveType, Base, None]
 StateVar = Union[PrimitiveType, Base, None]
 StateIterVar = Union[list, set, tuple]
 StateIterVar = Union[list, set, tuple]
 
 
-# ArgsSpec = Callable[[Var], list[Var]]
-ArgsSpec = Callable
+
+# Type for signatures mapping JS function args to Python function args.
+ArgsSpec = Callable[..., List]
 
 
 
 
 PrimitiveToAnnotation = {
 PrimitiveToAnnotation = {