Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 29, 2024
1 parent e35fd02 commit 80cdd41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
18 changes: 6 additions & 12 deletions pyflp/_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@
class ROProperty(Protocol[T_co]):
"""Protocol for a read-only descriptor."""

def __get__(self, ins: Any, owner: Any = None) -> T_co | Self | None:
...
def __get__(self, ins: Any, owner: Any = None) -> T_co | Self | None: ...


@runtime_checkable
class RWProperty(ROProperty[T], Protocol):
"""Protocol for a read-write descriptor."""

def __set__(self, ins: Any, value: T) -> None:
...
def __set__(self, ins: Any, value: T) -> None: ...


class NamedPropMixin:
Expand All @@ -59,12 +57,10 @@ def __init__(self, *ids: EventEnum, default: T | None = None, readonly: bool = F
self._readonly = readonly

@overload
def _get_event(self, ins: ItemModel[VE]) -> ItemModel[VE]:
...
def _get_event(self, ins: ItemModel[VE]) -> ItemModel[VE]: ...

@overload
def _get_event(self, ins: EventModel) -> AnyEvent | None:
...
def _get_event(self, ins: EventModel) -> AnyEvent | None: ...

def _get_event(self, ins: ItemModel[VE] | EventModel):
if isinstance(ins, ItemModel):
Expand All @@ -85,12 +81,10 @@ def default(self) -> T | None: # Configure version based defaults here
return self._default

@abc.abstractmethod
def _get(self, ev_or_ins: Any) -> T | None:
...
def _get(self, ev_or_ins: Any) -> T | None: ...

@abc.abstractmethod
def _set(self, ev_or_ins: Any, value: T) -> None:
...
def _set(self, ev_or_ins: Any, value: T) -> None: ...

@final
def __get__(self, ins: Any, owner: Any = None) -> T | Self | None:
Expand Down
12 changes: 4 additions & 8 deletions pyflp/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,20 @@ def __eq__(self, o: object) -> bool:
@runtime_checkable
class ModelCollection(Iterable[MT_co], Protocol[MT_co]):
@overload
def __getitem__(self, i: int | str) -> MT_co:
...
def __getitem__(self, i: int | str) -> MT_co: ...

@overload
def __getitem__(self, i: slice) -> Sequence[MT_co]:
...
def __getitem__(self, i: slice) -> Sequence[MT_co]: ...


def supports_slice(func: Callable[[ModelCollection[MT_co], str | int | slice], MT_co]):
"""Wraps a :meth:`ModelCollection.__getitem__` to return a sequence if required."""

@overload
def wrapper(self: ModelCollection[MT_co], i: int | str) -> MT_co:
...
def wrapper(self: ModelCollection[MT_co], i: int | str) -> MT_co: ...

@overload
def wrapper(self: ModelCollection[MT_co], i: slice) -> Sequence[MT_co]:
...
def wrapper(self: ModelCollection[MT_co], i: slice) -> Sequence[MT_co]: ...

@functools.wraps(func)
def wrapper(self: Any, i: Any) -> MT_co | Sequence[MT_co]:
Expand Down

0 comments on commit 80cdd41

Please sign in to comment.