fix black lint (#1193)

This commit is contained in:
Ryan Morshead 2024-02-10 10:59:16 -08:00 committed by GitHub
parent 3a3ad3f706
commit 21011917ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 43 additions and 67 deletions

View file

@ -24,9 +24,9 @@ def Grid():
"style": { "style": {
"height": "30px", "height": "30px",
"width": "30px", "width": "30px",
"background_color": "black" "background_color": (
if index in selected_indices "black" if index in selected_indices else "white"
else "white", ),
"outline": "1px solid grey", "outline": "1px solid grey",
"cursor": "pointer", "cursor": "pointer",
}, },

View file

@ -21,9 +21,9 @@ def Grid():
"style": { "style": {
"height": "30px", "height": "30px",
"width": "30px", "width": "30px",
"background_color": "black" "background_color": (
if index in selected_indices "black" if index in selected_indices else "white"
else "white", ),
"outline": "1px solid grey", "outline": "1px solid grey",
"cursor": "pointer", "cursor": "pointer",
}, },

View file

@ -12,10 +12,10 @@ detached = true
dependencies = [ dependencies = [
"invoke", "invoke",
# lint # lint
"black", "black==24.1.1", # Pin lint tools we don't control to avoid breaking changes
"ruff==0.0.278", # Ruff is moving really fast, so pinning for now. "ruff==0.0.278", # Pin lint tools we don't control to avoid breaking changes
"toml", "toml",
"flake8", "flake8==7.0.0", # Pin lint tools we don't control to avoid breaking changes
"flake8-pyproject", "flake8-pyproject",
"reactpy-flake8 >=0.7", "reactpy-flake8 >=0.7",
# types # types

View file

@ -13,8 +13,7 @@ T = TypeVar("T")
class EffectFunc(Protocol): class EffectFunc(Protocol):
async def __call__(self, stop: Event) -> None: async def __call__(self, stop: Event) -> None: ...
...
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

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

View file

@ -42,13 +42,11 @@ _Type = TypeVar("_Type")
@overload @overload
def use_state(initial_value: Callable[[], _Type]) -> State[_Type]: def use_state(initial_value: Callable[[], _Type]) -> State[_Type]: ...
...
@overload @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]: def use_state(initial_value: _Type | Callable[[], _Type]) -> State[_Type]:
@ -105,16 +103,14 @@ _EffectApplyFunc: TypeAlias = "_SyncEffectFunc | _AsyncEffectFunc"
def use_effect( def use_effect(
function: None = None, function: None = None,
dependencies: Sequence[Any] | ellipsis | None = ..., dependencies: Sequence[Any] | ellipsis | None = ...,
) -> Callable[[_EffectApplyFunc], None]: ) -> Callable[[_EffectApplyFunc], None]: ...
...
@overload @overload
def use_effect( def use_effect(
function: _EffectApplyFunc, function: _EffectApplyFunc,
dependencies: Sequence[Any] | ellipsis | None = ..., dependencies: Sequence[Any] | ellipsis | None = ...,
) -> None: ) -> None: ...
...
def use_effect( def use_effect(
@ -313,16 +309,14 @@ _CallbackFunc = TypeVar("_CallbackFunc", bound=Callable[..., Any])
def use_callback( def use_callback(
function: None = None, function: None = None,
dependencies: Sequence[Any] | ellipsis | None = ..., dependencies: Sequence[Any] | ellipsis | None = ...,
) -> Callable[[_CallbackFunc], _CallbackFunc]: ) -> Callable[[_CallbackFunc], _CallbackFunc]: ...
...
@overload @overload
def use_callback( def use_callback(
function: _CallbackFunc, function: _CallbackFunc,
dependencies: Sequence[Any] | ellipsis | None = ..., dependencies: Sequence[Any] | ellipsis | None = ...,
) -> _CallbackFunc: ) -> _CallbackFunc: ...
...
def use_callback( def use_callback(
@ -358,24 +352,21 @@ def use_callback(
class _LambdaCaller(Protocol): class _LambdaCaller(Protocol):
"""MyPy doesn't know how to deal with TypeVars only used in function return""" """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 @overload
def use_memo( def use_memo(
function: None = None, function: None = None,
dependencies: Sequence[Any] | ellipsis | None = ..., dependencies: Sequence[Any] | ellipsis | None = ...,
) -> _LambdaCaller: ) -> _LambdaCaller: ...
...
@overload @overload
def use_memo( def use_memo(
function: Callable[[], _Type], function: Callable[[], _Type],
dependencies: Sequence[Any] | ellipsis | None = ..., dependencies: Sequence[Any] | ellipsis | None = ...,
) -> _Type: ) -> _Type: ...
...
def use_memo( def use_memo(

View file

@ -159,8 +159,7 @@ EventHandlerDict: TypeAlias = "dict[str, EventHandlerType]"
class EventHandlerFunc(Protocol): class EventHandlerFunc(Protocol):
"""A coroutine which can handle event data""" """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 @runtime_checkable
@ -192,18 +191,17 @@ class VdomDictConstructor(Protocol):
"""Standard function for constructing a :class:`VdomDict`""" """Standard function for constructing a :class:`VdomDict`"""
@overload @overload
def __call__(self, attributes: VdomAttributes, *children: VdomChildren) -> VdomDict: def __call__(
... self, attributes: VdomAttributes, *children: VdomChildren
) -> VdomDict: ...
@overload @overload
def __call__(self, *children: VdomChildren) -> VdomDict: def __call__(self, *children: VdomChildren) -> VdomDict: ...
...
@overload @overload
def __call__( def __call__(
self, *attributes_and_children: VdomAttributes | VdomChildren self, *attributes_and_children: VdomAttributes | VdomChildren
) -> VdomDict: ) -> VdomDict: ...
...
class LayoutUpdateMessage(TypedDict): class LayoutUpdateMessage(TypedDict):
@ -236,8 +234,7 @@ class Context(Protocol[_Type]):
*children: Any, *children: Any,
value: _Type = ..., value: _Type = ...,
key: Key | None = ..., key: Key | None = ...,
) -> ContextProviderType[_Type]: ) -> ContextProviderType[_Type]: ...
...
class ContextProviderType(ComponentType, Protocol[_Type]): class ContextProviderType(ComponentType, Protocol[_Type]):

View file

@ -125,13 +125,11 @@ def is_vdom(value: Any) -> bool:
@overload @overload
def vdom(tag: str, *children: VdomChildren) -> VdomDict: def vdom(tag: str, *children: VdomChildren) -> VdomDict: ...
...
@overload @overload
def vdom(tag: str, attributes: VdomAttributes, *children: VdomChildren) -> VdomDict: def vdom(tag: str, attributes: VdomAttributes, *children: VdomChildren) -> VdomDict: ...
...
def vdom( def vdom(
@ -345,8 +343,7 @@ class _CustomVdomDictConstructor(Protocol):
children: Sequence[VdomChild], children: Sequence[VdomChild],
key: Key | None, key: Key | None,
event_handlers: EventHandlerDict, event_handlers: EventHandlerDict,
) -> VdomDict: ) -> VdomDict: ...
...
class _EllipsisRepr: class _EllipsisRepr:

View file

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

View file

@ -82,8 +82,7 @@ _CastTo_co = TypeVar("_CastTo_co", covariant=True)
class _CastFunc(Protocol[_CastTo_co]): class _CastFunc(Protocol[_CastTo_co]):
def __call__(self, value: str) -> _CastTo_co: def __call__(self, value: str) -> _CastTo_co: ...
...
if TYPE_CHECKING: if TYPE_CHECKING:

View file

@ -106,9 +106,9 @@ def test_rewrite_camel_case_props_declarations_no_files():
None, None,
), ),
], ],
ids=lambda item: " ".join(map(str.strip, item.split())) ids=lambda item: (
if isinstance(item, str) " ".join(map(str.strip, item.split())) if isinstance(item, str) else item
else item, ),
) )
def test_generate_rewrite(source, expected): def test_generate_rewrite(source, expected):
actual = generate_rewrite(Path("test.py"), dedent(source).strip()) actual = generate_rewrite(Path("test.py"), dedent(source).strip())

View file

@ -225,9 +225,9 @@ def test_rewrite_key_declarations_no_files():
None, None,
), ),
], ],
ids=lambda item: " ".join(map(str.strip, item.split())) ids=lambda item: (
if isinstance(item, str) " ".join(map(str.strip, item.split())) if isinstance(item, str) else item
else item, ),
) )
def test_generate_rewrite(source, expected): def test_generate_rewrite(source, expected):
actual = generate_rewrite(Path("test.py"), dedent(source).strip()) actual = generate_rewrite(Path("test.py"), dedent(source).strip())

View file

@ -48,8 +48,7 @@ def no_logged_errors():
def test_layout_repr(): def test_layout_repr():
@reactpy.component @reactpy.component
def MyComponent(): def MyComponent(): ...
...
my_component = MyComponent() my_component = MyComponent()
layout = reactpy.Layout(my_component) 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): async def test_layout_cannot_be_used_outside_context_manager(caplog):
@reactpy.component @reactpy.component
def Component(): def Component(): ...
...
component = Component() component = Component()
layout = reactpy.Layout(component) layout = reactpy.Layout(component)

View file

@ -28,8 +28,7 @@ if TYPE_CHECKING:
class ReleasePrepFunc(Protocol): class ReleasePrepFunc(Protocol):
def __call__( def __call__(
self, context: Context, package: PackageInfo self, context: Context, package: PackageInfo
) -> Callable[[bool], None]: ) -> Callable[[bool], None]: ...
...
LanguageName: TypeAlias = "Literal['py', 'js']" LanguageName: TypeAlias = "Literal['py', 'js']"