From d6e743889b2f0dd1ba17af07a985e062799d1239 Mon Sep 17 00:00:00 2001 From: Ryan Morshead Date: Sat, 10 Feb 2024 11:54:32 -0700 Subject: [PATCH] fix black lint --- .../_examples/set_remove.py | 6 ++--- .../_examples/set_update.py | 6 ++--- pyproject.toml | 6 ++--- .../reactpy/reactpy/core/_life_cycle_hook.py | 3 +-- src/py/reactpy/reactpy/core/events.py | 6 ++--- src/py/reactpy/reactpy/core/hooks.py | 27 +++++++------------ src/py/reactpy/reactpy/core/types.py | 17 +++++------- src/py/reactpy/reactpy/core/vdom.py | 9 +++---- src/py/reactpy/reactpy/web/module.py | 6 ++--- src/py/reactpy/reactpy/widgets.py | 3 +-- .../test_rewrite_camel_case_props.py | 6 ++--- .../tests/test__console/test_rewrite_keys.py | 6 ++--- src/py/reactpy/tests/test_core/test_layout.py | 6 ++--- tasks.py | 3 +-- 14 files changed, 43 insertions(+), 67 deletions(-) diff --git a/docs/source/guides/adding-interactivity/dangers-of-mutability/_examples/set_remove.py b/docs/source/guides/adding-interactivity/dangers-of-mutability/_examples/set_remove.py index be5366cb2..abe55a918 100644 --- a/docs/source/guides/adding-interactivity/dangers-of-mutability/_examples/set_remove.py +++ b/docs/source/guides/adding-interactivity/dangers-of-mutability/_examples/set_remove.py @@ -24,9 +24,9 @@ def handle_click(event): "style": { "height": "30px", "width": "30px", - "background_color": "black" - if index in selected_indices - else "white", + "background_color": ( + "black" if index in selected_indices else "white" + ), "outline": "1px solid grey", "cursor": "pointer", }, diff --git a/docs/source/guides/adding-interactivity/dangers-of-mutability/_examples/set_update.py b/docs/source/guides/adding-interactivity/dangers-of-mutability/_examples/set_update.py index 8ff2e1ca4..27f170a42 100644 --- a/docs/source/guides/adding-interactivity/dangers-of-mutability/_examples/set_update.py +++ b/docs/source/guides/adding-interactivity/dangers-of-mutability/_examples/set_update.py @@ -21,9 +21,9 @@ def handle_click(event): "style": { "height": "30px", "width": "30px", - "background_color": "black" - if index in selected_indices - else "white", + "background_color": ( + "black" if index in selected_indices else "white" + ), "outline": "1px solid grey", "cursor": "pointer", }, diff --git a/pyproject.toml b/pyproject.toml index 3cf94e23f..775ab01a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,10 +12,10 @@ detached = true dependencies = [ "invoke", # lint - "black", - "ruff==0.0.278", # Ruff is moving really fast, so pinning for now. + "black==24.1.1", # Pin lint tools we don't control to avoid breaking changes + "ruff==0.0.278", # Pin lint tools we don't control to avoid breaking changes "toml", - "flake8", + "flake8==7.0.0", # Pin lint tools we don't control to avoid breaking changes "flake8-pyproject", "reactpy-flake8 >=0.7", # types diff --git a/src/py/reactpy/reactpy/core/_life_cycle_hook.py b/src/py/reactpy/reactpy/core/_life_cycle_hook.py index ea5e6d634..88d3386a8 100644 --- a/src/py/reactpy/reactpy/core/_life_cycle_hook.py +++ b/src/py/reactpy/reactpy/core/_life_cycle_hook.py @@ -13,8 +13,7 @@ class EffectFunc(Protocol): - async def __call__(self, stop: Event) -> None: - ... + async def __call__(self, stop: Event) -> None: ... logger = logging.getLogger(__name__) diff --git a/src/py/reactpy/reactpy/core/events.py b/src/py/reactpy/reactpy/core/events.py index cd5de3228..f715b7e9d 100644 --- a/src/py/reactpy/reactpy/core/events.py +++ b/src/py/reactpy/reactpy/core/events.py @@ -15,8 +15,7 @@ def event( *, stop_propagation: bool = ..., prevent_default: bool = ..., -) -> EventHandler: - ... +) -> EventHandler: ... @overload @@ -25,8 +24,7 @@ def event( *, stop_propagation: bool = ..., prevent_default: bool = ..., -) -> Callable[[Callable[..., Any]], EventHandler]: - ... +) -> Callable[[Callable[..., Any]], EventHandler]: ... def event( diff --git a/src/py/reactpy/reactpy/core/hooks.py b/src/py/reactpy/reactpy/core/hooks.py index 4513dadef..640cbf14c 100644 --- a/src/py/reactpy/reactpy/core/hooks.py +++ b/src/py/reactpy/reactpy/core/hooks.py @@ -42,13 +42,11 @@ @overload -def use_state(initial_value: Callable[[], _Type]) -> State[_Type]: - ... +def use_state(initial_value: Callable[[], _Type]) -> State[_Type]: ... @overload -def use_state(initial_value: _Type) -> State[_Type]: - ... +def use_state(initial_value: _Type) -> State[_Type]: ... def use_state(initial_value: _Type | Callable[[], _Type]) -> State[_Type]: @@ -105,16 +103,14 @@ def dispatch(new: _Type | Callable[[_Type], _Type]) -> None: def use_effect( function: None = None, dependencies: Sequence[Any] | ellipsis | None = ..., -) -> Callable[[_EffectApplyFunc], None]: - ... +) -> Callable[[_EffectApplyFunc], None]: ... @overload def use_effect( function: _EffectApplyFunc, dependencies: Sequence[Any] | ellipsis | None = ..., -) -> None: - ... +) -> None: ... def use_effect( @@ -313,16 +309,14 @@ def dispatch(action: _ActionType) -> None: def use_callback( function: None = None, dependencies: Sequence[Any] | ellipsis | None = ..., -) -> Callable[[_CallbackFunc], _CallbackFunc]: - ... +) -> Callable[[_CallbackFunc], _CallbackFunc]: ... @overload def use_callback( function: _CallbackFunc, dependencies: Sequence[Any] | ellipsis | None = ..., -) -> _CallbackFunc: - ... +) -> _CallbackFunc: ... def use_callback( @@ -358,24 +352,21 @@ def setup(function: _CallbackFunc) -> _CallbackFunc: class _LambdaCaller(Protocol): """MyPy doesn't know how to deal with TypeVars only used in function return""" - def __call__(self, func: Callable[[], _Type]) -> _Type: - ... + def __call__(self, func: Callable[[], _Type]) -> _Type: ... @overload def use_memo( function: None = None, dependencies: Sequence[Any] | ellipsis | None = ..., -) -> _LambdaCaller: - ... +) -> _LambdaCaller: ... @overload def use_memo( function: Callable[[], _Type], dependencies: Sequence[Any] | ellipsis | None = ..., -) -> _Type: - ... +) -> _Type: ... def use_memo( diff --git a/src/py/reactpy/reactpy/core/types.py b/src/py/reactpy/reactpy/core/types.py index 39a9b3534..b451be30a 100644 --- a/src/py/reactpy/reactpy/core/types.py +++ b/src/py/reactpy/reactpy/core/types.py @@ -159,8 +159,7 @@ class _JsonImportSource(TypedDict): class EventHandlerFunc(Protocol): """A coroutine which can handle event data""" - async def __call__(self, data: Sequence[Any]) -> None: - ... + async def __call__(self, data: Sequence[Any]) -> None: ... @runtime_checkable @@ -192,18 +191,17 @@ class VdomDictConstructor(Protocol): """Standard function for constructing a :class:`VdomDict`""" @overload - def __call__(self, attributes: VdomAttributes, *children: VdomChildren) -> VdomDict: - ... + def __call__( + self, attributes: VdomAttributes, *children: VdomChildren + ) -> VdomDict: ... @overload - def __call__(self, *children: VdomChildren) -> VdomDict: - ... + def __call__(self, *children: VdomChildren) -> VdomDict: ... @overload def __call__( self, *attributes_and_children: VdomAttributes | VdomChildren - ) -> VdomDict: - ... + ) -> VdomDict: ... class LayoutUpdateMessage(TypedDict): @@ -236,8 +234,7 @@ def __call__( *children: Any, value: _Type = ..., key: Key | None = ..., - ) -> ContextProviderType[_Type]: - ... + ) -> ContextProviderType[_Type]: ... class ContextProviderType(ComponentType, Protocol[_Type]): diff --git a/src/py/reactpy/reactpy/core/vdom.py b/src/py/reactpy/reactpy/core/vdom.py index 840a09c7c..e494b5269 100644 --- a/src/py/reactpy/reactpy/core/vdom.py +++ b/src/py/reactpy/reactpy/core/vdom.py @@ -125,13 +125,11 @@ def is_vdom(value: Any) -> bool: @overload -def vdom(tag: str, *children: VdomChildren) -> VdomDict: - ... +def vdom(tag: str, *children: VdomChildren) -> VdomDict: ... @overload -def vdom(tag: str, attributes: VdomAttributes, *children: VdomChildren) -> VdomDict: - ... +def vdom(tag: str, attributes: VdomAttributes, *children: VdomChildren) -> VdomDict: ... def vdom( @@ -345,8 +343,7 @@ def __call__( children: Sequence[VdomChild], key: Key | None, event_handlers: EventHandlerDict, - ) -> VdomDict: - ... + ) -> VdomDict: ... class _EllipsisRepr: diff --git a/src/py/reactpy/reactpy/web/module.py b/src/py/reactpy/reactpy/web/module.py index 48322fe24..c3192da4e 100644 --- a/src/py/reactpy/reactpy/web/module.py +++ b/src/py/reactpy/reactpy/web/module.py @@ -314,8 +314,7 @@ def export( export_names: str, fallback: Any | None = ..., allow_children: bool = ..., -) -> VdomDictConstructor: - ... +) -> VdomDictConstructor: ... @overload @@ -324,8 +323,7 @@ def export( export_names: list[str] | tuple[str, ...], fallback: Any | None = ..., allow_children: bool = ..., -) -> list[VdomDictConstructor]: - ... +) -> list[VdomDictConstructor]: ... def export( diff --git a/src/py/reactpy/reactpy/widgets.py b/src/py/reactpy/reactpy/widgets.py index 29f941447..63b45a7e0 100644 --- a/src/py/reactpy/reactpy/widgets.py +++ b/src/py/reactpy/reactpy/widgets.py @@ -82,8 +82,7 @@ def sync_inputs(event: dict[str, Any]) -> None: class _CastFunc(Protocol[_CastTo_co]): - def __call__(self, value: str) -> _CastTo_co: - ... + def __call__(self, value: str) -> _CastTo_co: ... if TYPE_CHECKING: diff --git a/src/py/reactpy/tests/test__console/test_rewrite_camel_case_props.py b/src/py/reactpy/tests/test__console/test_rewrite_camel_case_props.py index 47b8baabc..ca928cf3b 100644 --- a/src/py/reactpy/tests/test__console/test_rewrite_camel_case_props.py +++ b/src/py/reactpy/tests/test__console/test_rewrite_camel_case_props.py @@ -106,9 +106,9 @@ def test_rewrite_camel_case_props_declarations_no_files(): None, ), ], - ids=lambda item: " ".join(map(str.strip, item.split())) - if isinstance(item, str) - else item, + ids=lambda item: ( + " ".join(map(str.strip, item.split())) if isinstance(item, str) else item + ), ) def test_generate_rewrite(source, expected): actual = generate_rewrite(Path("test.py"), dedent(source).strip()) diff --git a/src/py/reactpy/tests/test__console/test_rewrite_keys.py b/src/py/reactpy/tests/test__console/test_rewrite_keys.py index da0b26c4f..95c49a019 100644 --- a/src/py/reactpy/tests/test__console/test_rewrite_keys.py +++ b/src/py/reactpy/tests/test__console/test_rewrite_keys.py @@ -225,9 +225,9 @@ def func(): None, ), ], - ids=lambda item: " ".join(map(str.strip, item.split())) - if isinstance(item, str) - else item, + ids=lambda item: ( + " ".join(map(str.strip, item.split())) if isinstance(item, str) else item + ), ) def test_generate_rewrite(source, expected): actual = generate_rewrite(Path("test.py"), dedent(source).strip()) diff --git a/src/py/reactpy/tests/test_core/test_layout.py b/src/py/reactpy/tests/test_core/test_layout.py index 6eec7a8d2..cfb544758 100644 --- a/src/py/reactpy/tests/test_core/test_layout.py +++ b/src/py/reactpy/tests/test_core/test_layout.py @@ -48,8 +48,7 @@ def no_logged_errors(): def test_layout_repr(): @reactpy.component - def MyComponent(): - ... + def MyComponent(): ... my_component = MyComponent() layout = reactpy.Layout(my_component) @@ -65,8 +64,7 @@ def test_layout_expects_abstract_component(): async def test_layout_cannot_be_used_outside_context_manager(caplog): @reactpy.component - def Component(): - ... + def Component(): ... component = Component() layout = reactpy.Layout(component) diff --git a/tasks.py b/tasks.py index 65f75b208..e11d291e3 100644 --- a/tasks.py +++ b/tasks.py @@ -28,8 +28,7 @@ class ReleasePrepFunc(Protocol): def __call__( self, context: Context, package: PackageInfo - ) -> Callable[[bool], None]: - ... + ) -> Callable[[bool], None]: ... LanguageName: TypeAlias = "Literal['py', 'js']"