Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -11,16 +11,16 @@ repos:
- id: check-added-large-files
- id: requirements-txt-fixer
- id: check-vcs-permalinks
- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.1.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.277
rev: v0.15.1
hooks:
- id: ruff
- repo: https://github.com/asottile/pyupgrade
rev: v3.9.0
rev: v3.21.2
hooks:
- id: pyupgrade
args: ["--py38-plus"]
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
9 changes: 2 additions & 7 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
def test_project(project: Project):
assert project.artists == "demberto"
assert project.channel_count == 19
assert (
project.comments
== textwrap.dedent(
"""\
assert project.comments == textwrap.dedent("""\
This is a testing FLP used by PyFLP - An FL Studio project file parser.

Notes for contributors:
Expand All @@ -25,9 +22,7 @@ def test_project(project: Project):

Terms:
"item(s)": Refers to a channel, insert, slot, track, pattern, timemarker, etc.
"""
).replace("\n", "\r")
) # Who the hell uses \r?
""").replace("\n", "\r") # Who the hell uses \r?
assert project.created_on == datetime.datetime(2022, 9, 16, 20, 47, 12, 746000)
assert project.data_path == pathlib.Path("")
assert project.format == FileFormat.Project
Expand Down
Loading