From 70da032c2710700635c12d9b6f9a66ea757bb8f6 Mon Sep 17 00:00:00 2001 From: slackroo Date: Wed, 19 Feb 2025 14:45:49 +0530 Subject: [PATCH] removed codespell ignores and pyright type checking ignores --- reflex/base.py | 4 ++-- reflex/compiler/utils.py | 2 +- reflex/event.py | 4 ++-- reflex/utils/telemetry.py | 2 +- reflex/utils/types.py | 6 ++---- reflex/vars/dep_tracking.py | 4 ++-- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/reflex/base.py b/reflex/base.py index 5a0eb2c10..34ed8262b 100644 --- a/reflex/base.py +++ b/reflex/base.py @@ -35,11 +35,11 @@ def validate_field_name(bases: List[Type["BaseModel"]], field_name: str) -> None for base in bases: if not reload and getattr(base, field_name, None): pass - except TypeError as te: # codespell:ignore te + except TypeError as e: raise VarNameError( f'State var "{field_name}" in {base} has been shadowed by a substate var; ' f'use a different field name instead".' - ) from te # codespell:ignore te + ) from e # monkeypatch pydantic validate_field_name method to skip validating diff --git a/reflex/compiler/utils.py b/reflex/compiler/utils.py index c8425c892..c66dfe304 100644 --- a/reflex/compiler/utils.py +++ b/reflex/compiler/utils.py @@ -180,7 +180,7 @@ def save_error(error: Exception) -> str: timestamp = datetime.now().strftime("%Y-%m-%d__%H-%M-%S") constants.Reflex.LOGS_DIR.mkdir(parents=True, exist_ok=True) log_path = constants.Reflex.LOGS_DIR / f"error_{timestamp}.log" - traceback.TracebackException.from_exception(error).print(file=log_path.open("w+")) # type: ignore[attr-defined] + traceback.TracebackException.from_exception(error).print(file=log_path.open("w+")) return str(log_path) diff --git a/reflex/event.py b/reflex/event.py index 6f97e1027..36d67b225 100644 --- a/reflex/event.py +++ b/reflex/event.py @@ -1299,10 +1299,10 @@ def call_event_handler( compare_result = typehint_issubclass( args_types_without_vars[i], type_hints_of_provided_callback[arg] ) - except TypeError as te: # codespell:ignore te + except TypeError as e: raise TypeError( f"Could not compare types {args_types_without_vars[i]} and {type_hints_of_provided_callback[arg]} for argument {arg} of {event_callback.fn.__qualname__} provided for {key}." - ) from te # codespell:ignore te + ) from e if compare_result: type_match_found[arg] = True diff --git a/reflex/utils/telemetry.py b/reflex/utils/telemetry.py index 2a0f52d84..ecfd52428 100644 --- a/reflex/utils/telemetry.py +++ b/reflex/utils/telemetry.py @@ -12,7 +12,7 @@ from contextlib import suppress from reflex.config import environment try: - from datetime import UTC, datetime # type: ignore[attr-defined] + from datetime import UTC, datetime except ImportError: from datetime import datetime diff --git a/reflex/utils/types.py b/reflex/utils/types.py index 4f9563f90..d1080621b 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -516,12 +516,10 @@ def _issubclass(cls: GenericType, cls_check: GenericType, instance: Any = None) # Check if the types match. try: return cls_check_base == Any or issubclass(cls_base, cls_check_base) - except TypeError as te: # codespell:ignore te + except TypeError as e: # These errors typically arise from bad annotations and are hard to # debug without knowing the type that we tried to compare. - raise TypeError( - f"Invalid type for issubclass: {cls_base}" - ) from te # codespell:ignore te + raise TypeError(f"Invalid type for issubclass: {cls_base}") from e def does_obj_satisfy_typed_dict(obj: Any, cls: GenericType) -> bool: diff --git a/reflex/vars/dep_tracking.py b/reflex/vars/dep_tracking.py index 197b125e4..0b2367799 100644 --- a/reflex/vars/dep_tracking.py +++ b/reflex/vars/dep_tracking.py @@ -239,8 +239,8 @@ class DependencyTracker: """ # Get the original source code and eval it to get the Var. module = inspect.getmodule(self.func) - positions0 = self._getting_var_instructions[0].positions # type: ignore[attr-defined] - positions1 = self._getting_var_instructions[-1].positions # type: ignore[attr-defined] + positions0 = self._getting_var_instructions[0].positions + positions1 = self._getting_var_instructions[-1].positions if module is None or positions0 is None or positions1 is None: raise VarValueError( f"Cannot determine the source code for the var in {self.func!r}."