diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 54d8f3d72..73a22b728 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ fail_fast: true repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.8.2 + rev: v0.9.3 hooks: - id: ruff-format args: [reflex, tests] diff --git a/pyproject.toml b/pyproject.toml index d19d1a0ac..5fbee109e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,7 +61,7 @@ dill = ">=0.3.8" toml = ">=0.10.2,<1.0" pytest-asyncio = ">=0.24.0" pytest-cov = ">=4.0.0,<7.0" -ruff = "0.8.2" +ruff = "0.9.3" pandas = ">=2.1.1,<3.0" pillow = ">=10.0.0,<12.0" plotly = ">=5.13.0,<6.0" @@ -86,7 +86,7 @@ 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"] -lint.ignore = ["B008", "D205", "E501", "F403", "SIM115", "RUF006", "RUF012", "TRY0"] +lint.ignore = ["B008", "D205", "E501", "F403", "SIM115", "RUF006", "RUF008", "RUF012", "TRY0"] lint.pydocstyle.convention = "google" [tool.ruff.lint.per-file-ignores] diff --git a/reflex/app.py b/reflex/app.py index 2e9765d21..a8b94189d 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -1280,7 +1280,7 @@ class App(MiddlewareMixin, LifespanMixin): ): raise ValueError( f"Provided custom {handler_domain} exception handler `{_fn_name}` has the wrong argument order." - f"Expected `{required_arg}` as the {required_arg_index+1} argument but got `{list(arg_annotations.keys())[required_arg_index]}`" + f"Expected `{required_arg}` as the {required_arg_index + 1} argument but got `{list(arg_annotations.keys())[required_arg_index]}`" ) if not issubclass(arg_annotations[required_arg], Exception): diff --git a/reflex/components/component.py b/reflex/components/component.py index 58bdfe7c2..1333bc6c6 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -625,8 +625,7 @@ class Component(BaseComponent, ABC): if props is None: # Add component props to the tag. props = { - attr[:-1] if attr.endswith("_") else attr: getattr(self, attr) - for attr in self.get_props() + attr.removesuffix("_"): getattr(self, attr) for attr in self.get_props() } # Add ref to element if `id` is not None. diff --git a/reflex/components/datadisplay/dataeditor.py b/reflex/components/datadisplay/dataeditor.py index f71f97713..492ff3367 100644 --- a/reflex/components/datadisplay/dataeditor.py +++ b/reflex/components/datadisplay/dataeditor.py @@ -345,7 +345,7 @@ class DataEditor(NoSSRComponent): data_callback = f"getData_{editor_id}" self.get_cell_content = Var(_js_expr=data_callback) # type: ignore - code = [f"function {data_callback}([col, row])" "{"] + code = [f"function {data_callback}([col, row]){{"] columns_path = str(self.columns) data_path = str(self.data) diff --git a/reflex/custom_components/custom_components.py b/reflex/custom_components/custom_components.py index 8000e7f4c..1f13734e0 100644 --- a/reflex/custom_components/custom_components.py +++ b/reflex/custom_components/custom_components.py @@ -772,7 +772,7 @@ def _validate_project_info(): pyproject_toml = _get_package_config() project = pyproject_toml["project"] console.print( - f'Double check the information before publishing: {project["name"]} version {project["version"]}' + f"Double check the information before publishing: {project['name']} version {project['version']}" ) console.print("Update or enter to keep the current information.") @@ -784,7 +784,7 @@ def _validate_project_info(): author["name"] = console.ask("Author Name", default=author.get("name", "")) author["email"] = console.ask("Author Email", default=author.get("email", "")) - console.print(f'Current keywords are: {project.get("keywords") or []}') + console.print(f"Current keywords are: {project.get('keywords') or []}") keyword_action = console.ask( "Keep, replace or append?", choices=["k", "r", "a"], default="k" ) diff --git a/reflex/event.py b/reflex/event.py index 96c2c30b9..dcfd6907b 100644 --- a/reflex/event.py +++ b/reflex/event.py @@ -332,7 +332,7 @@ class EventSpec(EventActionsMixin): arg = None try: for arg in args: - values.append(LiteralVar.create(value=arg)) # noqa: PERF401 + values.append(LiteralVar.create(value=arg)) # noqa: PERF401, RUF100 except TypeError as e: raise EventHandlerTypeError( f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}." diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index 66c9156a9..397ff9fab 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -1851,7 +1851,7 @@ def initialize_main_module_index_from_generation(app_name: str, generation_hash: [ resp.text, "", - "" "def index() -> rx.Component:", + "def index() -> rx.Component:", f" return {render_func_name}()", "", "", diff --git a/reflex/vars/base.py b/reflex/vars/base.py index a3b3059e9..d59ea5fee 100644 --- a/reflex/vars/base.py +++ b/reflex/vars/base.py @@ -444,7 +444,7 @@ class Var(Generic[VAR_TYPE]): _default_var_type: ClassVar[GenericType] = default_type - ToVarOperation.__name__ = f'To{cls.__name__.removesuffix("Var")}Operation' + ToVarOperation.__name__ = f"To{cls.__name__.removesuffix('Var')}Operation" _var_subclasses.append(VarSubclassEntry(cls, ToVarOperation, python_types)) diff --git a/reflex/vars/datetime.py b/reflex/vars/datetime.py index b6f4c24c6..751797306 100644 --- a/reflex/vars/datetime.py +++ b/reflex/vars/datetime.py @@ -185,7 +185,7 @@ def date_compare_operation( The result of the operation. """ return var_operation_return( - f"({lhs} { '<' if strict else '<='} {rhs})", + f"({lhs} {'<' if strict else '<='} {rhs})", bool, ) diff --git a/tests/integration/test_connection_banner.py b/tests/integration/test_connection_banner.py index c2a912af6..5ccb6c7cb 100644 --- a/tests/integration/test_connection_banner.py +++ b/tests/integration/test_connection_banner.py @@ -89,9 +89,9 @@ async def test_connection_banner(connection_banner: AppHarness): driver = connection_banner.frontend() ss = SessionStorage(driver) - assert connection_banner._poll_for( - lambda: ss.get("token") is not None - ), "token not found" + assert connection_banner._poll_for(lambda: ss.get("token") is not None), ( + "token not found" + ) assert connection_banner._poll_for(lambda: not has_error_modal(driver)) diff --git a/tests/units/components/core/test_colors.py b/tests/units/components/core/test_colors.py index c1295fb41..4bad71240 100644 --- a/tests/units/components/core/test_colors.py +++ b/tests/units/components/core/test_colors.py @@ -55,13 +55,13 @@ def create_color_var(color): Color, ), ( - create_color_var(f'{rx.color(ColorState.color, f"{ColorState.shade}")}'), # type: ignore + create_color_var(f"{rx.color(ColorState.color, f'{ColorState.shade}')}"), # type: ignore f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.shade+")")', str, ), ( create_color_var( - f'{rx.color(f"{ColorState.color}", f"{ColorState.shade}")}' # type: ignore + f"{rx.color(f'{ColorState.color}', f'{ColorState.shade}')}" # type: ignore ), f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.shade+")")', str,