Skip to content

Commit

Permalink
fix black lint (#1193)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea authored Feb 10, 2024
1 parent 3a3ad3f commit 2101191
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/py/reactpy/reactpy/core/_life_cycle_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
6 changes: 2 additions & 4 deletions src/py/reactpy/reactpy/core/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ def event(
*,
stop_propagation: bool = ...,
prevent_default: bool = ...,
) -> EventHandler:
...
) -> EventHandler: ...


@overload
Expand All @@ -25,8 +24,7 @@ def event(
*,
stop_propagation: bool = ...,
prevent_default: bool = ...,
) -> Callable[[Callable[..., Any]], EventHandler]:
...
) -> Callable[[Callable[..., Any]], EventHandler]: ...


def event(
Expand Down
27 changes: 9 additions & 18 deletions src/py/reactpy/reactpy/core/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
17 changes: 7 additions & 10 deletions src/py/reactpy/reactpy/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -236,8 +234,7 @@ def __call__(
*children: Any,
value: _Type = ...,
key: Key | None = ...,
) -> ContextProviderType[_Type]:
...
) -> ContextProviderType[_Type]: ...


class ContextProviderType(ComponentType, Protocol[_Type]):
Expand Down
9 changes: 3 additions & 6 deletions src/py/reactpy/reactpy/core/vdom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -345,8 +343,7 @@ def __call__(
children: Sequence[VdomChild],
key: Key | None,
event_handlers: EventHandlerDict,
) -> VdomDict:
...
) -> VdomDict: ...


class _EllipsisRepr:
Expand Down
6 changes: 2 additions & 4 deletions src/py/reactpy/reactpy/web/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ def export(
export_names: str,
fallback: Any | None = ...,
allow_children: bool = ...,
) -> VdomDictConstructor:
...
) -> VdomDictConstructor: ...


@overload
Expand All @@ -324,8 +323,7 @@ def export(
export_names: list[str] | tuple[str, ...],
fallback: Any | None = ...,
allow_children: bool = ...,
) -> list[VdomDictConstructor]:
...
) -> list[VdomDictConstructor]: ...


def export(
Expand Down
3 changes: 1 addition & 2 deletions src/py/reactpy/reactpy/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions src/py/reactpy/tests/test__console/test_rewrite_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 2 additions & 4 deletions src/py/reactpy/tests/test_core/test_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']"

Expand Down

0 comments on commit 2101191

Please sign in to comment.