upgrade to latest ruff (#3497)

* upgrade to latest ruff

* try to fix dep review

* try to fix dep review (2)

* upgrade black

* upgrade black (2)

* update allowed dependencies

* update allowed dependencies (2)

* update allowed dependencies (3)

* wait between interim and final in yield test

* remove previous commit, increase delay between yield

* forgot to save on the time.sleep(1) removal

* fix integration (maybe?)

* fix pyi?

* what even is going on

* what is realityi?

* test another fix for app harness

* try to wait even longer?

* force uvloop to be optional

* downpin fastapi < 0.111, remove changes to test
This commit is contained in:
Thomas Brandého 2024-06-19 12:32:13 +02:00 committed by GitHub
parent d6d14b3f72
commit 0d39237b3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
179 changed files with 690 additions and 678 deletions

View File

@ -13,5 +13,5 @@ jobs:
- name: 'Dependency Review'
uses: actions/dependency-review-action@v4
with:
allow-licenses: Apache-2.0, BSD-2-Clause, BSD-3-Clause, HPND, ISC, MIT, MPL-2.0, PSF-2.0, Unlicense
allow-dependencies-licenses: 'pkg:pypi/lazy-loader'
allow-licenses: Apache-2.0, BSD-2-Clause, BSD-3-Clause, HPND, ISC, MIT, MPL-2.0, Unlicense, Python-2.0, Python-2.0.1, Apache-2.0 AND MIT, BSD-2-Clause AND BSD-3-Clause, Apache-2.0 AND BSD-3-Clause
allow-dependencies-licenses: 'pkg:pypi/lazy-loader'

View File

@ -3,7 +3,7 @@ fail_fast: true
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.0
rev: v0.4.9
hooks:
- id: ruff-format
args: [integration, reflex, tests]
@ -11,6 +11,16 @@ repos:
args: ["--fix", "--exit-non-zero-on-fix"]
exclude: '^integration/benchmarks/'
# Run pyi check before pyright because pyright can fail if pyi files are wrong.
- repo: local
hooks:
- id: update-pyi-files
name: update-pyi-files
always_run: true
language: system
description: 'Update pyi files as needed'
entry: python3 scripts/make_pyi.py
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.313
hooks:
@ -24,11 +34,3 @@ repos:
- id: darglint
exclude: '^reflex/reflex.py'
- repo: local
hooks:
- id: update-pyi-files
name: update-pyi-files
always_run: true
language: system
description: 'Update pyi files as needed'
entry: python3 scripts/make_pyi.py

View File

@ -1,4 +1,5 @@
"""Simple module which contains one reusable reflex state class."""
import reflex as rx

View File

@ -1,4 +1,5 @@
"""Integration tests for client side storage."""
from __future__ import annotations
from typing import Generator

View File

@ -1,4 +1,5 @@
"""Integration tests for client side storage."""
from __future__ import annotations
import time

View File

@ -1,4 +1,5 @@
"""Integration tests for dynamic route page behavior."""
from __future__ import annotations
from typing import Callable, Coroutine, Generator, Type

View File

@ -1,4 +1,5 @@
"""Ensure stopPropagation and preventDefault work as expected."""
from __future__ import annotations
import asyncio

View File

@ -1,4 +1,5 @@
"""Ensure that Event Chains are properly queued and handled between frontend and backend."""
from __future__ import annotations
from typing import Generator

View File

@ -1,4 +1,5 @@
"""Integration tests for forms."""
import functools
import time
from typing import Generator

View File

@ -1,4 +1,5 @@
"""Integration tests for text input and related components."""
from typing import Generator
import pytest

View File

@ -1,4 +1,5 @@
"""Test large state."""
import time
import jinja2

View File

@ -1,4 +1,5 @@
"""Test cases for the FastAPI lifespan integration."""
from typing import Generator
import pytest

View File

@ -1,4 +1,5 @@
"""Integration tests for client side storage."""
from __future__ import annotations
from typing import Generator

View File

@ -1,4 +1,5 @@
"""Integration tests for media components."""
from typing import Generator
import pytest

View File

@ -1,4 +1,5 @@
"""Integration tests for links and related components."""
from typing import Generator
from urllib.parse import urlsplit

View File

@ -1,4 +1,5 @@
"""Integration tests for special server side events."""
import time
from typing import Generator

View File

@ -1,4 +1,5 @@
"""Test shared state."""
from __future__ import annotations
from typing import Generator

View File

@ -1,4 +1,5 @@
"""Integration tests for table and related components."""
from typing import Generator
import pytest

View File

@ -1,4 +1,5 @@
"""Integration tests for file upload."""
from __future__ import annotations
import asyncio

View File

@ -1,4 +1,5 @@
"""Integration tests for all urls in Reflex."""
import os
import re
from pathlib import Path

View File

@ -1,4 +1,5 @@
"""Integration tests for var operations."""
from typing import Generator
import pytest

View File

@ -1,4 +1,5 @@
"""Helper utilities for integration tests."""
from __future__ import annotations
from contextlib import contextmanager

1111
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@ packages = [
[tool.poetry.dependencies]
python = "^3.8"
dill = ">=0.3.8,<0.4"
fastapi = ">=0.96.0,<1.0"
fastapi = ">=0.96.0,<0.111.0"
gunicorn = ">=20.1.0,<23.0"
jinja2 = ">=3.1.2,<4.0"
psutil = ">=5.9.4,<6.0"
@ -73,8 +73,8 @@ darglint = ">=1.8.1,<2.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-cov = ">=4.0.0,<5.0"
black = "^22.10.0,<23.0"
ruff = "0.1.0"
black = "^24.3.0"
ruff = "^0.4.9"
pandas = [
{version = ">=2.1.1,<3.0", python = ">=3.9,<3.13"},
{version = ">=1.5.3,<2.0", python = ">=3.8,<3.9"},
@ -99,9 +99,11 @@ build-backend = "poetry.core.masonry.api"
[tool.ruff]
exclude = ["*.pyi"]
target-version = "py37"
target-version = "py38"
lint.select = ["B", "D", "E", "F", "I", "SIM", "W"]
lint.ignore = ["B008", "D203", "D205", "D213", "D401", "D406", "D407", "E501", "F403", "F405", "F541"]
lint.pydocstyle.convention = "google"
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"tests/*.py" = ["D100", "D103", "D104", "B018"]

View File

@ -1,4 +1,5 @@
"""Welcome to Reflex! This file outlines the steps to create a basic app."""
from typing import Callable
import reflex as rx

View File

@ -1,4 +1,5 @@
"""The pages of the app."""
from .chatapp import chatapp_page
from .datatable import datatable_page
from .forms import forms_page

View File

@ -1,4 +1,5 @@
"""The settings page for the template."""
from typing import Any
import reflex as rx

View File

@ -1,4 +1,5 @@
"""The settings page for the template."""
import reflex as rx
from ..states.form_state import FormState, UploadState

View File

@ -1,4 +1,5 @@
"""The dashboard page for the template."""
import reflex as rx
from ..states.pie_state import PieChartState

View File

@ -1,4 +1,5 @@
"""The home page of the app."""
import reflex as rx
from ..styles import *

View File

@ -1,4 +1,5 @@
"""Styles for the app."""
import reflex as rx
from .state import State

View File

@ -1,4 +1,5 @@
"""The Reflex Admin Dashboard."""
from dataclasses import dataclass, field
from typing import Optional

View File

@ -176,9 +176,9 @@ class App(LifespanMixin, Base):
stylesheets: List[str] = []
# A component that is present on every page (defaults to the Connection Error banner).
overlay_component: Optional[
Union[Component, ComponentCallable]
] = default_overlay_component
overlay_component: Optional[Union[Component, ComponentCallable]] = (
default_overlay_component
)
# Components to add to the head of every page.
head_components: List[Component] = []

View File

@ -1,6 +1,7 @@
"""Shims the real reflex app module for running backend server (uvicorn or gunicorn).
Only the app attribute is explicitly exposed.
"""
from concurrent.futures import ThreadPoolExecutor
from reflex import constants
@ -8,7 +9,7 @@ from reflex.utils import telemetry
from reflex.utils.exec import is_prod_mode
from reflex.utils.prerequisites import get_app
if "app" != constants.CompileVars.APP:
if constants.CompileVars.APP != "app":
raise AssertionError("unexpected variable name for 'app'")
telemetry.send("compile")

View File

@ -1,4 +1,5 @@
"""Import all the components."""
from __future__ import annotations
from reflex.utils import lazy_loader

View File

@ -1,4 +1,5 @@
"""Base components."""
from __future__ import annotations
from reflex.utils import lazy_loader

View File

@ -1,4 +1,5 @@
"""Top-level component that wraps the entire app."""
from reflex.components.base.fragment import Fragment
from reflex.components.component import Component
from reflex.vars import Var

View File

@ -1,4 +1,5 @@
"""React fragments to enable bare returns of component trees from functions."""
from reflex.components.component import Component

View File

@ -1,6 +1,5 @@
"""Display the title of the current page."""
from reflex.components.component import Component
from reflex.vars import Var

View File

@ -2,6 +2,7 @@
https://nextjs.org/docs/app/api-reference/components/script
"""
from __future__ import annotations
from reflex.components.component import Component

View File

@ -1,4 +1,5 @@
"""Components that are based on Chakra-UI."""
from __future__ import annotations
from functools import lru_cache

View File

@ -155,6 +155,7 @@ class ChakraProvider(ChakraComponent):
A new ChakraProvider component.
"""
...
def add_imports(self) -> ImportDict: ...
chakra_provider = ChakraProvider.create()

View File

@ -1,4 +1,5 @@
"""A code component."""
from reflex.components.chakra import (
ChakraComponent,
)

View File

@ -1,4 +1,5 @@
"""A line to divide parts of the layout."""
from typing import Literal
from reflex.components.chakra import ChakraComponent, LiteralDividerVariant

View File

@ -1,4 +1,5 @@
"""Table components."""
from typing import List, Tuple
from reflex.components.chakra import ChakraComponent

View File

@ -184,6 +184,7 @@ class Thead(ChakraComponent):
"""
...
@staticmethod
def validate_headers(headers): ...
@ -264,6 +265,7 @@ class Tbody(ChakraComponent):
Component: The table body component
"""
...
@staticmethod
def validate_rows(rows): ...
@ -344,6 +346,7 @@ class Tfoot(ChakraComponent):
The table footer component.
"""
...
@staticmethod
def validate_footers(footers): ...

View File

@ -1,4 +1,5 @@
"""Chakra Tag Component."""
from typing import Optional
from reflex.components.chakra import (

View File

@ -1,4 +1,5 @@
"""A transition Component."""
from typing import Union
from reflex.components.chakra import ChakraComponent

View File

@ -1,4 +1,5 @@
"""Container to stack elements with spacing."""
from typing import Union
from reflex.components.chakra import ChakraComponent

View File

@ -1,4 +1,5 @@
"""A button component."""
from typing import List
from reflex.components.chakra import (

View File

@ -1,4 +1,5 @@
"""A checkbox component."""
from __future__ import annotations
from reflex.components.chakra import (

View File

@ -14,6 +14,7 @@ rx.text(
)
```
"""
from __future__ import annotations
from reflex.components.chakra import ChakraComponent

View File

@ -1,4 +1,5 @@
"""An editable component."""
from __future__ import annotations
from reflex.components.chakra import ChakraComponent

View File

@ -1,4 +1,5 @@
"""Form components."""
from __future__ import annotations
from reflex.components.chakra import ChakraComponent

View File

@ -1,6 +1,5 @@
"""An input component."""
from reflex.components.chakra import (
ChakraComponent,
LiteralButtonSize,

View File

@ -1,4 +1,5 @@
"""Provides a feature-rich Select and some (not all) related components."""
from __future__ import annotations
from typing import Any, Dict, List, Optional, Set, Union

View File

@ -1,6 +1,5 @@
"""A radio component."""
from typing import Any, List
from reflex.components.chakra import ChakraComponent

View File

@ -1,4 +1,5 @@
"""A range slider component."""
from __future__ import annotations
from typing import List, Optional

View File

@ -1,4 +1,5 @@
"""A slider component."""
from __future__ import annotations
from typing import Literal

View File

@ -1,4 +1,5 @@
"""A switch component."""
from __future__ import annotations
from reflex.components.chakra import ChakraComponent, LiteralColorScheme

View File

@ -1,4 +1,5 @@
"""A textarea component."""
from __future__ import annotations
from reflex.components.chakra import ChakraComponent, LiteralInputVariant

View File

@ -1,4 +1,5 @@
"""Avatar components."""
from __future__ import annotations
from reflex.components.chakra import ChakraComponent, LiteralAvatarSize

View File

@ -1,4 +1,5 @@
"""An icon component."""
from typing import List
from reflex.components.chakra import ChakraComponent

View File

@ -1,4 +1,5 @@
"""An image component."""
from __future__ import annotations
from typing import Any, Optional

View File

@ -1,6 +1,5 @@
"""A link component."""
from reflex.components.chakra import ChakraComponent
from reflex.components.component import Component
from reflex.components.next.link import NextLink

View File

@ -1,4 +1,5 @@
"""Alert dialog components."""
from __future__ import annotations
from reflex.components.chakra import ChakraComponent, LiteralAlertDialogSize

View File

@ -1,4 +1,5 @@
"""Container to stack elements with spacing."""
from __future__ import annotations
from reflex.components.chakra import (

View File

@ -1,4 +1,5 @@
"""Menu components."""
from __future__ import annotations
from typing import List, Optional

View File

@ -1,4 +1,5 @@
"""Modal components."""
from __future__ import annotations
from typing import Literal, Optional, Union

View File

@ -1,4 +1,5 @@
"""Popover components."""
from __future__ import annotations
from reflex.components.chakra import (

View File

@ -1,4 +1,5 @@
"""Tooltip components."""
from __future__ import annotations
from reflex.components.chakra import ChakraComponent, LiteralChakraDirection

View File

@ -1,6 +1,5 @@
"""A heading component."""
from reflex.components.chakra import ChakraComponent, LiteralHeadingSize
from reflex.vars import Var

View File

@ -1,4 +1,5 @@
"""A span component."""
from __future__ import annotations
from reflex.components.chakra import ChakraComponent

View File

@ -1,4 +1,5 @@
"""A text component."""
from __future__ import annotations
from reflex.components.chakra import ChakraComponent

View File

@ -1,4 +1,5 @@
"""Core Reflex components."""
from __future__ import annotations
from reflex.utils import lazy_loader

View File

@ -445,6 +445,7 @@ class WifiOffPulse(Icon):
The icon component with default props applied.
"""
...
def add_imports(self) -> dict[str, str | ImportVar | list[str | ImportVar]]: ...
class ConnectionPulser(Div):

View File

@ -7,6 +7,7 @@ setting a reactive state var "routeNotFound" to true if the redirect fails. The
`wait_for_client_redirect` function will render the component only after
routeNotFound becomes true.
"""
from __future__ import annotations
from reflex import constants

View File

@ -110,18 +110,15 @@ class Cond(MemoizationLeaf):
@overload
def cond(condition: Any, c1: Component, c2: Any) -> Component:
...
def cond(condition: Any, c1: Component, c2: Any) -> Component: ...
@overload
def cond(condition: Any, c1: Component) -> Component:
...
def cond(condition: Any, c1: Component) -> Component: ...
@overload
def cond(condition: Any, c1: Any, c2: Any) -> Var:
...
def cond(condition: Any, c1: Any, c2: Any) -> Var: ...
def cond(condition: Any, c1: Any, c2: Any = None):

View File

@ -1,4 +1,5 @@
"""Create a list of components from an iterable."""
from __future__ import annotations
import inspect

View File

@ -1,4 +1,5 @@
"""A html component."""
from typing import Dict
from reflex.components.el.elements.typography import Div

View File

@ -1,4 +1,5 @@
"""Data grid components."""
from __future__ import annotations
from reflex.utils import lazy_loader

View File

@ -1,4 +1,5 @@
"""A code component."""
from __future__ import annotations
import re

View File

@ -1112,6 +1112,7 @@ class CodeBlock(Component):
The text component.
"""
...
def add_style(self): ...
@staticmethod
def convert_theme_name(theme) -> str: ...

View File

@ -1,4 +1,5 @@
"""A Reflex logo component."""
import reflex as rx

View File

@ -1,4 +1,5 @@
"""The el package exports raw HTML elements."""
from __future__ import annotations
from reflex.utils import lazy_loader

View File

@ -1,6 +1,5 @@
"""Base class definition for raw HTML elements."""
from reflex.components.component import Component

View File

@ -1,4 +1,5 @@
"""Element classes."""
from __future__ import annotations
from reflex.utils import lazy_loader

View File

@ -1,4 +1,5 @@
"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
from typing import Union
from reflex.components.el.element import Element

View File

@ -580,6 +580,7 @@ class Form(BaseHTML):
The form component.
"""
...
def add_imports(self) -> ImportDict: ...
def add_hooks(self) -> list[str]: ...

View File

@ -1,4 +1,5 @@
"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
from typing import Union
from reflex.vars import Var

View File

@ -1,4 +1,5 @@
"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
from typing import Any, Union
from reflex import Component

View File

@ -1,4 +1,5 @@
"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
from typing import Union
from reflex.components.el.element import Element

View File

@ -1,4 +1,5 @@
"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
from typing import Union
from reflex.vars import Var as Var

View File

@ -1,4 +1,5 @@
"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
from typing import Union
from reflex.vars import Var as Var

View File

@ -1,4 +1,5 @@
"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
from typing import Union
from reflex.vars import Var as Var

View File

@ -1,4 +1,5 @@
"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
from typing import Union
from reflex.vars import Var as Var

View File

@ -181,4 +181,5 @@ class DataTable(Gridjs):
ValueError: If a pandas dataframe is passed in and columns are also provided.
"""
...
def add_imports(self) -> ImportDict: ...

View File

@ -242,7 +242,9 @@ class Markdown(Component):
}
# Separate out inline code and code blocks.
components["code"] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
components[
"code"
] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
const match = (className || '').match(/language-(?<lang>.*)/);
const language = match ? match[1] : '';
if (language) {{

View File

@ -123,6 +123,7 @@ class Markdown(Component):
The markdown component.
"""
...
def add_imports(self) -> ImportDict | list[ImportDict]: ...
def get_component(self, tag: str, **props) -> Component: ...
def format_component(self, tag: str, **props) -> str: ...

View File

@ -1,2 +1,3 @@
"""Shim for reflex.components.chakra.media.icon."""
from reflex.components.chakra.media.icon import *

Some files were not shown because too many files have changed in this diff Show More