diff --git a/.github/workflows/check_export.yml b/.github/workflows/check_export.yml index ee2fec77..ac88e21e 100644 --- a/.github/workflows/check_export.yml +++ b/.github/workflows/check_export.yml @@ -29,6 +29,7 @@ jobs: check-export: needs: [list-examples] strategy: + fail-fast: false matrix: example: ${{ fromJSON(needs.list-examples.outputs.examples) }} runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f6625e6e..e63103fc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,16 @@ +fail_fast: true + repos: - - repo: local - hooks: - - id: black - name: black - description: "Black: The uncompromising Python code formatter" - entry: black - language: python - minimum_pre_commit_version: 2.9.2 - require_serial: true - types_or: [python] \ No newline at end of file + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.8.5 + hooks: + - id: ruff-format + args: ["."] + - id: ruff + args: ["--fix", "--exit-non-zero-on-fix"] + + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: ["--skip=*.txt,*.json,*.svg", "--exclude-file=reflexle/reflexle/words.py", "--ignore-words-list=HomeState,selectin", "."] diff --git a/ag_grid_finance/ag_grid_finance/ag_grid_finance.py b/ag_grid_finance/ag_grid_finance/ag_grid_finance.py index ca499ecc..e86c6301 100644 --- a/ag_grid_finance/ag_grid_finance/ag_grid_finance.py +++ b/ag_grid_finance/ag_grid_finance/ag_grid_finance.py @@ -36,7 +36,10 @@ def fetch_stock_data(self): # Fetch data for all tickers in a single download self.data = yf.download( - companies, start=start_date, end=self.datetime_now, group_by="ticker", + companies, + start=start_date, + end=self.datetime_now, + group_by="ticker", ) rows = [] for ticker in companies: diff --git a/azure_auth/azure_auth/auth/core.py b/azure_auth/azure_auth/auth/core.py index 3b34e862..6a0756f2 100644 --- a/azure_auth/azure_auth/auth/core.py +++ b/azure_auth/azure_auth/auth/core.py @@ -68,8 +68,8 @@ def callback(self): result = sso_app.acquire_token_by_auth_code_flow( self._flow, auth_response, scopes=[] ) - except Exception as e: - return rx.toast(f"error something went wrong") + except Exception: + return rx.toast("error something went wrong") # this can be used for accessing graph self._access_token = result.get("access_token") self._token = result.get("id_token_claims") diff --git a/azure_auth/azure_auth/azure_auth.py b/azure_auth/azure_auth/azure_auth.py index 433a513f..cbfd3c7d 100644 --- a/azure_auth/azure_auth/azure_auth.py +++ b/azure_auth/azure_auth/azure_auth.py @@ -2,8 +2,7 @@ import reflex as rx -from rxconfig import config -from azure_auth.pages import callback, home, logout +from azure_auth.pages import callback, home, logout # noqa: F401 class State(rx.State): diff --git a/basic_crud/basic_crud/basic_crud.py b/basic_crud/basic_crud/basic_crud.py index 0799fd53..c4c2d48c 100644 --- a/basic_crud/basic_crud/basic_crud.py +++ b/basic_crud/basic_crud/basic_crud.py @@ -136,7 +136,7 @@ def render_product(product: Product): ), rx.spacer(), border="solid black 1px", - spcaing="5", + spacing="5", width="100%", ) diff --git a/chat_v2/chat_v2/components/buttons.py b/chat_v2/chat_v2/components/buttons.py index 7bc066e4..7bdb40b7 100644 --- a/chat_v2/chat_v2/components/buttons.py +++ b/chat_v2/chat_v2/components/buttons.py @@ -1,7 +1,6 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Callable import reflex as rx diff --git a/chat_v2/chat_v2/components/typography.py b/chat_v2/chat_v2/components/typography.py index 9673e53f..adb72cf7 100644 --- a/chat_v2/chat_v2/components/typography.py +++ b/chat_v2/chat_v2/components/typography.py @@ -11,7 +11,7 @@ def text_with_icon( """Creates a text with an icon. - icon: The icon tag name. - text: The title name. - - kwargs: Additonal props for the component. + - kwargs: Additional props for the component. """ return rx.hstack( rx.icon( diff --git a/chat_v2/chat_v2/page_chat/chat_body.py b/chat_v2/chat_v2/page_chat/chat_body.py index c036f524..e4280e28 100644 --- a/chat_v2/chat_v2/page_chat/chat_body.py +++ b/chat_v2/chat_v2/page_chat/chat_body.py @@ -12,7 +12,6 @@ from chat_v2.page_chat.chat_messages.model_chat_message_question import ( QUESTION_STYLE, ) -from chat_v2.templates.action_bar import action_bar from chat_v2.templates.pop_up import dialog_library diff --git a/data_visualisation/data_visualisation/data_visualisation.py b/data_visualisation/data_visualisation/data_visualisation.py index 4fd5da4b..f99820bc 100644 --- a/data_visualisation/data_visualisation/data_visualisation.py +++ b/data_visualisation/data_visualisation/data_visualisation.py @@ -3,7 +3,7 @@ from sqlmodel import select import reflex as rx -from data_visualisation.models import Customer, Cereals, Covid, Countries +from data_visualisation.models import Customer, Cereals, Covid, Countries # noqa: F401 from data_visualisation.data_loading import loading_data @@ -57,7 +57,7 @@ def add_item(self): session.add(MODEL(**self.current_item)) session.commit() self.load_entries() - return rx.window_alert(f"Item has been added.") + return rx.window_alert("Item has been added.") def update_item(self): """Update an item in the database.""" @@ -66,7 +66,7 @@ def update_item(self): select(MODEL).where(MODEL.id == self.current_item["id"]) ).first() - for field in MODEL.get_fields(): + for field in MODEL.__fields__: if field != "id": setattr(item, field, self.current_item[field]) session.add(item) @@ -156,11 +156,7 @@ def add_item_ui(): ), rx.form( rx.flex( - *[ - add_fields(field) - for field in MODEL.get_fields() - if field != "id" - ], + *[add_fields(field) for field in MODEL.__fields__ if field != "id"], rx.box( rx.button( "Submit", @@ -225,7 +221,7 @@ def update_item_ui(item): update_fields_and_attrs( field, getattr(State.current_item, field) ) - for field in MODEL.get_fields() + for field in MODEL.__fields__ if field != "id" ], rx.box( @@ -294,7 +290,7 @@ def show_item(item: MODEL): rx.table.cell(rx.avatar(fallback="DA")), *[ rx.table.cell(getattr(item, field)) - for field in MODEL.get_fields() + for field in MODEL.__fields__ if field != "id" ], rx.table.cell( @@ -323,7 +319,7 @@ def content(): ), rx.spacer(), rx.select( - [*[field for field in MODEL.get_fields() if field != "id"]], + [*[field for field in MODEL.__fields__ if field != "id"]], placeholder="Sort By: Name", size="3", on_change=lambda sort_value: State.sort_values(sort_value), @@ -340,7 +336,7 @@ def content(): rx.table.column_header_cell("Icon"), *[ rx.table.column_header_cell(field) - for field in MODEL.get_fields() + for field in MODEL.__fields__ if field != "id" ], rx.table.column_header_cell("Edit"), diff --git a/form-designer/form_designer/form_designer.py b/form-designer/form_designer/form_designer.py index 640370be..b516b739 100644 --- a/form-designer/form_designer/form_designer.py +++ b/form-designer/form_designer/form_designer.py @@ -1,4 +1,3 @@ -import contextlib import reflex as rx import reflex_local_auth diff --git a/form-designer/tests/test_login.py b/form-designer/tests/test_login.py index 523ae982..abdb5368 100644 --- a/form-designer/tests/test_login.py +++ b/form-designer/tests/test_login.py @@ -1,5 +1,4 @@ import re -import time import pytest import reflex as rx diff --git a/linkinbio/README.md b/linkinbio/README.md index 1d5d52f3..a0d330db 100644 --- a/linkinbio/README.md +++ b/linkinbio/README.md @@ -87,4 +87,4 @@ Contributions are welcome! Please fork the repository and submit a pull request ## Contact -This template was created by @erinmikailstaples (https://github.com/erinmikailstaples). Feel free to reach out for any quesitons, feedback, or collaboration opportunities. \ No newline at end of file +This template was created by @erinmikailstaples (https://github.com/erinmikailstaples). Feel free to reach out for any questions, feedback, or collaboration opportunities. \ No newline at end of file diff --git a/linkinbio/linkinbio/linkinbio.py b/linkinbio/linkinbio/linkinbio.py index 519242fd..29dfea71 100644 --- a/linkinbio/linkinbio/linkinbio.py +++ b/linkinbio/linkinbio/linkinbio.py @@ -1,5 +1,5 @@ import reflex as rx -from linkinbio.style import * +from linkinbio.style import style # add launchdarkly imports import ldclient diff --git a/overkey/overkey/overkey.py b/overkey/overkey/overkey.py index 535b925c..144b4b9a 100644 --- a/overkey/overkey/overkey.py +++ b/overkey/overkey/overkey.py @@ -294,7 +294,7 @@ def index() -> rx.Component: rx.vstack( rx.hstack( rx.cond( - (OverkeyState.current_time != None), + OverkeyState.current_time.is_not_none(), rx.fragment( rx.icon_button( "rotate-ccw", diff --git a/quiz/quiz/quiz.py b/quiz/quiz/quiz.py index ebf5c6c6..0a9ef0ca 100644 --- a/quiz/quiz/quiz.py +++ b/quiz/quiz/quiz.py @@ -1,7 +1,6 @@ """Welcome to Reflex! This file outlines the steps to create a basic app.""" import copy -import time from typing import Any, List import reflex as rx diff --git a/traversal/traversal/traversal.py b/traversal/traversal/traversal.py index 21c6a432..f7bb63bb 100644 --- a/traversal/traversal/traversal.py +++ b/traversal/traversal/traversal.py @@ -98,12 +98,10 @@ def set_initial_values(self): def path_found(self, i, j): if self.colored_graph[i][j] == "green": - return rx._x.toast.success( - f"Path found to [{i},{j}]", position="top-center" - ) + return rx.toast.success(f"Path found to [{i},{j}]", position="top-center") def path_not_found(self): - return rx._x.toast.error("No path found", position="top-center") + return rx.toast.error("No path found", position="top-center") def explore_neighbors(self, i, j, mode=None): if self.colored_graph[i][j] != "red": diff --git a/twitter/twitter/components/__init__.py b/twitter/twitter/components/__init__.py index 5915d283..9d699ce9 100644 --- a/twitter/twitter/components/__init__.py +++ b/twitter/twitter/components/__init__.py @@ -1,3 +1,3 @@ """Re-export components.""" -from .container import container +from .container import container as container diff --git a/twitter/twitter/layouts/__init__.py b/twitter/twitter/layouts/__init__.py index bd3b1c09..ee920018 100644 --- a/twitter/twitter/layouts/__init__.py +++ b/twitter/twitter/layouts/__init__.py @@ -1,3 +1,3 @@ """Re-export layouts.""" -from .auth import auth_layout +from .auth import auth_layout as auth_layout diff --git a/twitter/twitter/pages/__init__.py b/twitter/twitter/pages/__init__.py index 2b474546..a59baddd 100644 --- a/twitter/twitter/pages/__init__.py +++ b/twitter/twitter/pages/__init__.py @@ -1,5 +1,5 @@ """Re-export pages.""" -from .home import home -from .login import login -from .signup import signup +from .home import home as home +from .login import login as login +from .signup import signup as signup diff --git a/upload/upload/upload.py b/upload/upload/upload.py index 51a55b53..35a0cd10 100644 --- a/upload/upload/upload.py +++ b/upload/upload/upload.py @@ -1,4 +1,3 @@ -import os from pathlib import Path from typing import List @@ -28,9 +27,13 @@ async def handle_upload(self, files: List[rx.UploadFile]): # Iterate through the uploaded files. for file in files: upload_data = await file.read() - outfile = Path(rx.get_upload_dir()) / file.filename.lstrip("/") - outfile.parent.mkdir(parents=True, exist_ok=True) - outfile.write_bytes(upload_data) + if file.name: + outfile = Path(rx.get_upload_dir()) / file.name.lstrip("/") + outfile.parent.mkdir(parents=True, exist_ok=True) + outfile.write_bytes(upload_data) + else: + # Unlikely to happens but make pyright happy to check for empty file names. + yield rx.toast("File name is empty. Please select a valid file.") def on_upload_progress(self, prog: dict): print("Got progress", prog)