update ruff to latest version (#4081)

* update ruff to latest version

* fix pyi
This commit is contained in:
Thomas Brandého 2024-10-07 14:52:36 -07:00 committed by GitHub
parent bec73109d6
commit 0e99ce91c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 53 additions and 53 deletions

View File

@ -3,7 +3,7 @@ fail_fast: true
repos: repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.10 rev: v0.6.9
hooks: hooks:
- id: ruff-format - id: ruff-format
args: [reflex, tests] args: [reflex, tests]
@ -25,7 +25,7 @@ repos:
rev: v1.1.313 rev: v1.1.313
hooks: hooks:
- id: pyright - id: pyright
args: [integration, reflex, tests] args: [reflex, tests]
language: system language: system
- repo: https://github.com/terrencepreilly/darglint - repo: https://github.com/terrencepreilly/darglint

39
poetry.lock generated
View File

@ -2255,28 +2255,29 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"]
[[package]] [[package]]
name = "ruff" name = "ruff"
version = "0.4.10" version = "0.6.9"
description = "An extremely fast Python linter and code formatter, written in Rust." description = "An extremely fast Python linter and code formatter, written in Rust."
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
{file = "ruff-0.4.10-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:5c2c4d0859305ac5a16310eec40e4e9a9dec5dcdfbe92697acd99624e8638dac"}, {file = "ruff-0.6.9-py3-none-linux_armv6l.whl", hash = "sha256:064df58d84ccc0ac0fcd63bc3090b251d90e2a372558c0f057c3f75ed73e1ccd"},
{file = "ruff-0.4.10-py3-none-macosx_11_0_arm64.whl", hash = "sha256:a79489607d1495685cdd911a323a35871abfb7a95d4f98fc6f85e799227ac46e"}, {file = "ruff-0.6.9-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:140d4b5c9f5fc7a7b074908a78ab8d384dd7f6510402267bc76c37195c02a7ec"},
{file = "ruff-0.4.10-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b1dd1681dfa90a41b8376a61af05cc4dc5ff32c8f14f5fe20dba9ff5deb80cd6"}, {file = "ruff-0.6.9-py3-none-macosx_11_0_arm64.whl", hash = "sha256:53fd8ca5e82bdee8da7f506d7b03a261f24cd43d090ea9db9a1dc59d9313914c"},
{file = "ruff-0.4.10-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c75c53bb79d71310dc79fb69eb4902fba804a81f374bc86a9b117a8d077a1784"}, {file = "ruff-0.6.9-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:645d7d8761f915e48a00d4ecc3686969761df69fb561dd914a773c1a8266e14e"},
{file = "ruff-0.4.10-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18238c80ee3d9100d3535d8eb15a59c4a0753b45cc55f8bf38f38d6a597b9739"}, {file = "ruff-0.6.9-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eae02b700763e3847595b9d2891488989cac00214da7f845f4bcf2989007d577"},
{file = "ruff-0.4.10-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d8f71885bce242da344989cae08e263de29752f094233f932d4f5cfb4ef36a81"}, {file = "ruff-0.6.9-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7d5ccc9e58112441de8ad4b29dcb7a86dc25c5f770e3c06a9d57e0e5eba48829"},
{file = "ruff-0.4.10-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:330421543bd3222cdfec481e8ff3460e8702ed1e58b494cf9d9e4bf90db52b9d"}, {file = "ruff-0.6.9-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:417b81aa1c9b60b2f8edc463c58363075412866ae4e2b9ab0f690dc1e87ac1b5"},
{file = "ruff-0.4.10-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9e9b6fb3a37b772628415b00c4fc892f97954275394ed611056a4b8a2631365e"}, {file = "ruff-0.6.9-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c866b631f5fbce896a74a6e4383407ba7507b815ccc52bcedabb6810fdb3ef7"},
{file = "ruff-0.4.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f54c481b39a762d48f64d97351048e842861c6662d63ec599f67d515cb417f6"}, {file = "ruff-0.6.9-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7b118afbb3202f5911486ad52da86d1d52305b59e7ef2031cea3425142b97d6f"},
{file = "ruff-0.4.10-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:67fe086b433b965c22de0b4259ddfe6fa541c95bf418499bedb9ad5fb8d1c631"}, {file = "ruff-0.6.9-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a67267654edc23c97335586774790cde402fb6bbdb3c2314f1fc087dee320bfa"},
{file = "ruff-0.4.10-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:acfaaab59543382085f9eb51f8e87bac26bf96b164839955f244d07125a982ef"}, {file = "ruff-0.6.9-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3ef0cc774b00fec123f635ce5c547dac263f6ee9fb9cc83437c5904183b55ceb"},
{file = "ruff-0.4.10-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3cea07079962b2941244191569cf3a05541477286f5cafea638cd3aa94b56815"}, {file = "ruff-0.6.9-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:12edd2af0c60fa61ff31cefb90aef4288ac4d372b4962c2864aeea3a1a2460c0"},
{file = "ruff-0.4.10-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:338a64ef0748f8c3a80d7f05785930f7965d71ca260904a9321d13be24b79695"}, {file = "ruff-0.6.9-py3-none-musllinux_1_2_i686.whl", hash = "sha256:55bb01caeaf3a60b2b2bba07308a02fca6ab56233302406ed5245180a05c5625"},
{file = "ruff-0.4.10-py3-none-win32.whl", hash = "sha256:ffe3cd2f89cb54561c62e5fa20e8f182c0a444934bf430515a4b422f1ab7b7ca"}, {file = "ruff-0.6.9-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:925d26471fa24b0ce5a6cdfab1bb526fb4159952385f386bdcc643813d472039"},
{file = "ruff-0.4.10-py3-none-win_amd64.whl", hash = "sha256:67f67cef43c55ffc8cc59e8e0b97e9e60b4837c8f21e8ab5ffd5d66e196e25f7"}, {file = "ruff-0.6.9-py3-none-win32.whl", hash = "sha256:eb61ec9bdb2506cffd492e05ac40e5bc6284873aceb605503d8494180d6fc84d"},
{file = "ruff-0.4.10-py3-none-win_arm64.whl", hash = "sha256:dd1fcee327c20addac7916ca4e2653fbbf2e8388d8a6477ce5b4e986b68ae6c0"}, {file = "ruff-0.6.9-py3-none-win_amd64.whl", hash = "sha256:785d31851c1ae91f45b3d8fe23b8ae4b5170089021fbb42402d811135f0b7117"},
{file = "ruff-0.4.10.tar.gz", hash = "sha256:3aa4f2bc388a30d346c56524f7cacca85945ba124945fe489952aadb6b5cd804"}, {file = "ruff-0.6.9-py3-none-win_arm64.whl", hash = "sha256:a9641e31476d601f83cd602608739a0840e348bda93fec9f1ee816f8b6798b93"},
{file = "ruff-0.6.9.tar.gz", hash = "sha256:b076ef717a8e5bc819514ee1d602bbdca5b4420ae13a9cf61a0c0a4f53a2baa2"},
] ]
[[package]] [[package]]
@ -3006,4 +3007,4 @@ type = ["pytest-mypy"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.9" python-versions = "^3.9"
content-hash = "73182556dcb255bdc74f3ea607b4c04dac29e31b78d8b498220584e5fd2d81f2" content-hash = "796ddba36f031ad2b47cae43ce6c49102e2cb98f92823b265d9779e6684333f6"

View File

@ -68,7 +68,7 @@ darglint = ">=1.8.1,<2.0"
toml = ">=0.10.2,<1.0" toml = ">=0.10.2,<1.0"
pytest-asyncio = ">=0.24.0" pytest-asyncio = ">=0.24.0"
pytest-cov = ">=4.0.0,<6.0" pytest-cov = ">=4.0.0,<6.0"
ruff = "^0.4.9" ruff = "^0.6.9"
pandas = ">=2.1.1,<3.0" pandas = ">=2.1.1,<3.0"
pillow = ">=10.0.0,<11.0" pillow = ">=10.0.0,<11.0"
plotly = ">=5.13.0,<6.0" plotly = ">=5.13.0,<6.0"

View File

@ -329,7 +329,7 @@ class DataEditor(NoSSRComponent):
columns = props.get("columns", []) columns = props.get("columns", [])
data = props.get("data", []) data = props.get("data", [])
rows = props.get("rows", None) rows = props.get("rows")
# If rows is not provided, determine from data. # If rows is not provided, determine from data.
if rows is None: if rows is None:

View File

@ -3,6 +3,7 @@
# This file was generated by `reflex/utils/pyi_generator.py`! # This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------ # ------------------------------------------------------
from . import elements as elements
from .elements.forms import Button as Button from .elements.forms import Button as Button
from .elements.forms import Fieldset as Fieldset from .elements.forms import Fieldset as Fieldset
from .elements.forms import Form as Form from .elements.forms import Form as Form

View File

@ -48,10 +48,10 @@ class IterTag(Tag):
""" """
iterable = self.iterable iterable = self.iterable
try: try:
if iterable._var_type.mro()[0] == dict: if iterable._var_type.mro()[0] is dict:
# Arg is a tuple of (key, value). # Arg is a tuple of (key, value).
return Tuple[get_args(iterable._var_type)] # type: ignore return Tuple[get_args(iterable._var_type)] # type: ignore
elif iterable._var_type.mro()[0] == tuple: elif iterable._var_type.mro()[0] is tuple:
# Arg is a union of any possible values in the tuple. # Arg is a union of any possible values in the tuple.
return Union[get_args(iterable._var_type)] # type: ignore return Union[get_args(iterable._var_type)] # type: ignore
else: else:

View File

@ -87,6 +87,4 @@ def sqlmodel_field_has_primary_key(field) -> bool:
return True return True
if getattr(field.field_info, "sa_column", None) is None: if getattr(field.field_info, "sa_column", None) is None:
return False return False
if getattr(field.field_info.sa_column, "primary_key", None) is True: return bool(getattr(field.field_info.sa_column, "primary_key", None))
return True
return False

View File

@ -94,9 +94,7 @@ def _raise_on_missing_project_hash() -> bool:
False when compilation should be skipped (i.e. no .web directory is required). False when compilation should be skipped (i.e. no .web directory is required).
Otherwise return True. Otherwise return True.
""" """
if should_skip_compile(): return not should_skip_compile()
return False
return True
def _prepare_event(event: str, **kwargs) -> dict: def _prepare_event(event: str, **kwargs) -> dict:

View File

@ -374,7 +374,7 @@ def get_base_class(cls: GenericType) -> Type:
if is_literal(cls): if is_literal(cls):
# only literals of the same type are supported. # only literals of the same type are supported.
arg_type = type(get_args(cls)[0]) arg_type = type(get_args(cls)[0])
if not all(type(arg) == arg_type for arg in get_args(cls)): if not all(type(arg) is arg_type for arg in get_args(cls)):
raise TypeError("only literals of the same type are supported") raise TypeError("only literals of the same type are supported")
return type(get_args(cls)[0]) return type(get_args(cls)[0])
@ -538,7 +538,7 @@ def is_backend_base_variable(name: str, cls: Type) -> bool:
if name in cls.__dict__: if name in cls.__dict__:
value = cls.__dict__[name] value = cls.__dict__[name]
if type(value) == classmethod: if type(value) is classmethod:
return False return False
if callable(value): if callable(value):
return False return False

View File

@ -239,7 +239,7 @@ class Var(Generic[VAR_TYPE]):
**kwargs, **kwargs,
) )
if (js_expr := kwargs.get("_js_expr", None)) is not None: if (js_expr := kwargs.get("_js_expr")) is not None:
object.__setattr__(value_with_replaced, "_js_expr", js_expr) object.__setattr__(value_with_replaced, "_js_expr", js_expr)
return value_with_replaced return value_with_replaced

View File

@ -45,7 +45,7 @@ def test_validate_cond(cond_state: BaseState):
Text.create("cond is True"), Text.create("cond is True"),
Text.create("cond is False"), Text.create("cond is False"),
) )
cond_dict = cond_component.render() if type(cond_component) == Fragment else {} cond_dict = cond_component.render() if type(cond_component) is Fragment else {}
assert cond_dict["name"] == "Fragment" assert cond_dict["name"] == "Fragment"
[condition] = cond_dict["children"] [condition] = cond_dict["children"]

View File

@ -67,7 +67,7 @@ class ComponentStateTest(ComponentState):
def display_color(color): def display_color(color):
assert color._var_type == str assert color._var_type is str
return box(text(color)) return box(text(color))
@ -106,18 +106,18 @@ def display_nested_color_with_shades_v2(color):
def display_color_tuple(color): def display_color_tuple(color):
assert color._var_type == str assert color._var_type is str
return box(text(color)) return box(text(color))
def display_colors_set(color): def display_colors_set(color):
assert color._var_type == str assert color._var_type is str
return box(text(color)) return box(text(color))
def display_nested_list_element(element: ArrayVar[List[str]], index: NumberVar[int]): def display_nested_list_element(element: ArrayVar[List[str]], index: NumberVar[int]):
assert element._var_type == List[str] assert element._var_type == List[str]
assert index._var_type == int assert index._var_type is int
return box(text(element[index])) return box(text(element[index]))
@ -240,7 +240,7 @@ def test_foreach_render(state_var, render_fn, render_dict):
arg_index = rend["arg_index"] arg_index = rend["arg_index"]
assert isinstance(arg_index, Var) assert isinstance(arg_index, Var)
assert arg_index._js_expr not in seen_index_vars assert arg_index._js_expr not in seen_index_vars
assert arg_index._var_type == int assert arg_index._var_type is int
seen_index_vars.add(arg_index._js_expr) seen_index_vars.add(arg_index._js_expr)

View File

@ -41,15 +41,15 @@ def test_match_components():
assert len(match_cases) == 6 assert len(match_cases) == 6
assert match_cases[0][0]._js_expr == "1" assert match_cases[0][0]._js_expr == "1"
assert match_cases[0][0]._var_type == int assert match_cases[0][0]._var_type is int
first_return_value_render = match_cases[0][1].render() first_return_value_render = match_cases[0][1].render()
assert first_return_value_render["name"] == "RadixThemesText" assert first_return_value_render["name"] == "RadixThemesText"
assert first_return_value_render["children"][0]["contents"] == '{"first value"}' assert first_return_value_render["children"][0]["contents"] == '{"first value"}'
assert match_cases[1][0]._js_expr == "2" assert match_cases[1][0]._js_expr == "2"
assert match_cases[1][0]._var_type == int assert match_cases[1][0]._var_type is int
assert match_cases[1][1]._js_expr == "3" assert match_cases[1][1]._js_expr == "3"
assert match_cases[1][1]._var_type == int assert match_cases[1][1]._var_type is int
second_return_value_render = match_cases[1][2].render() second_return_value_render = match_cases[1][2].render()
assert second_return_value_render["name"] == "RadixThemesText" assert second_return_value_render["name"] == "RadixThemesText"
assert second_return_value_render["children"][0]["contents"] == '{"second value"}' assert second_return_value_render["children"][0]["contents"] == '{"second value"}'
@ -61,7 +61,7 @@ def test_match_components():
assert third_return_value_render["children"][0]["contents"] == '{"third value"}' assert third_return_value_render["children"][0]["contents"] == '{"third value"}'
assert match_cases[3][0]._js_expr == '"random"' assert match_cases[3][0]._js_expr == '"random"'
assert match_cases[3][0]._var_type == str assert match_cases[3][0]._var_type is str
fourth_return_value_render = match_cases[3][1].render() fourth_return_value_render = match_cases[3][1].render()
assert fourth_return_value_render["name"] == "RadixThemesText" assert fourth_return_value_render["name"] == "RadixThemesText"
assert fourth_return_value_render["children"][0]["contents"] == '{"fourth value"}' assert fourth_return_value_render["children"][0]["contents"] == '{"fourth value"}'
@ -73,7 +73,7 @@ def test_match_components():
assert fifth_return_value_render["children"][0]["contents"] == '{"fifth value"}' assert fifth_return_value_render["children"][0]["contents"] == '{"fifth value"}'
assert match_cases[5][0]._js_expr == f"({MatchState.get_name()}.num + 1)" assert match_cases[5][0]._js_expr == f"({MatchState.get_name()}.num + 1)"
assert match_cases[5][0]._var_type == int assert match_cases[5][0]._var_type is int
fifth_return_value_render = match_cases[5][1].render() fifth_return_value_render = match_cases[5][1].render()
assert fifth_return_value_render["name"] == "RadixThemesText" assert fifth_return_value_render["name"] == "RadixThemesText"
assert fifth_return_value_render["children"][0]["contents"] == '{"sixth value"}' assert fifth_return_value_render["children"][0]["contents"] == '{"sixth value"}'

View File

@ -119,7 +119,7 @@ def test_format_cond_tag():
tag_dict["false_value"], tag_dict["false_value"],
) )
assert cond._js_expr == "logged_in" assert cond._js_expr == "logged_in"
assert cond._var_type == bool assert cond._var_type is bool
assert true_value["name"] == "h1" assert true_value["name"] == "h1"
assert true_value["contents"] == "True content" assert true_value["contents"] == "True content"

View File

@ -274,9 +274,9 @@ def test_base_class_vars(test_state):
assert isinstance(prop, Var) assert isinstance(prop, Var)
assert prop._js_expr.split(".")[-1] == field assert prop._js_expr.split(".")[-1] == field
assert cls.num1._var_type == int assert cls.num1._var_type is int
assert cls.num2._var_type == float assert cls.num2._var_type is float
assert cls.key._var_type == str assert cls.key._var_type is str
def test_computed_class_var(test_state): def test_computed_class_var(test_state):
@ -526,7 +526,7 @@ def test_set_class_var():
TestState._set_var(Var(_js_expr="num3", _var_type=int)._var_set_state(TestState)) TestState._set_var(Var(_js_expr="num3", _var_type=int)._var_set_state(TestState))
var = TestState.num3 # type: ignore var = TestState.num3 # type: ignore
assert var._js_expr == TestState.get_full_name() + ".num3" assert var._js_expr == TestState.get_full_name() + ".num3"
assert var._var_type == int assert var._var_type is int
assert var._var_state == TestState.get_full_name() assert var._var_state == TestState.get_full_name()

View File

@ -490,7 +490,7 @@ def test_var_indexing_str():
# Test that indexing gives a type of Var[str]. # Test that indexing gives a type of Var[str].
assert isinstance(str_var[0], Var) assert isinstance(str_var[0], Var)
assert str_var[0]._var_type == str assert str_var[0]._var_type is str
# Test basic indexing. # Test basic indexing.
assert str(str_var[0]) == "str.at(0)" assert str(str_var[0]) == "str.at(0)"
@ -623,7 +623,7 @@ def test_str_var_slicing():
# Test that slicing gives a type of Var[str]. # Test that slicing gives a type of Var[str].
assert isinstance(str_var[:1], Var) assert isinstance(str_var[:1], Var)
assert str_var[:1]._var_type == str assert str_var[:1]._var_type is str
# Test basic slicing. # Test basic slicing.
assert str(str_var[:1]) == 'str.split("").slice(undefined, 1).join("")' assert str(str_var[:1]) == 'str.split("").slice(undefined, 1).join("")'

View File

@ -542,7 +542,9 @@ def test_style_prop_with_event_handler_value(callable):
style = { style = {
"color": ( "color": (
EventHandler(fn=callable) if type(callable) != EventHandler else callable EventHandler(fn=callable)
if type(callable) is not EventHandler
else callable
) )
} }