Skip to content

Commit

Permalink
ci(pre-commit.ci): autoupdate (#264)
Browse files Browse the repository at this point in the history
* ci(pre-commit.ci): autoupdate

updates:
- [github.com/compilerla/conventional-pre-commit: v3.0.0 → v3.1.0](compilerla/conventional-pre-commit@v3.0.0...v3.1.0)
- [github.com/astral-sh/ruff-pre-commit: v0.1.9 → v0.2.0](astral-sh/ruff-pre-commit@v0.1.9...v0.2.0)
- [github.com/psf/black: 23.12.1 → 24.1.1](psf/black@23.12.1...24.1.1)
- [github.com/abravalheri/validate-pyproject: v0.15 → v0.16](abravalheri/validate-pyproject@v0.15...v0.16)

* style(pre-commit.ci): auto fixes [...]

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Talley Lambert <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and tlambert03 authored Feb 14, 2024
1 parent 4a1fc32 commit 80e1e73
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 99 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exclude: .asv

repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.0.0
rev: v3.1.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand All @@ -22,18 +22,18 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.2.0
hooks:
- id: ruff
args: [--fix, --unsafe-fixes]

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
rev: v0.16
hooks:
- id: validate-pyproject

Expand Down
1 change: 1 addition & 0 deletions benchmarks/_evented.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""This script isn't run by asv... but can be run directly to see how
evented dataclasses compare to non-evented dataclasses."""

import timeit
from dataclasses import dataclass
from typing import ClassVar
Expand Down
24 changes: 8 additions & 16 deletions src/psygnal/_dataclass_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ class DataClassType:


@overload
def is_dataclass(obj: type) -> TypeGuard[type[DataClassType]]:
...
def is_dataclass(obj: type) -> TypeGuard[type[DataClassType]]: ...


@overload
def is_dataclass(obj: object) -> TypeGuard[DataClassType]:
...
def is_dataclass(obj: object) -> TypeGuard[DataClassType]: ...


def is_dataclass(obj: object) -> TypeGuard[DataClassType]:
Expand All @@ -65,13 +63,11 @@ def is_dataclass(obj: object) -> TypeGuard[DataClassType]:


@overload
def is_attrs_class(obj: type) -> TypeGuard[type[AttrsType]]:
...
def is_attrs_class(obj: type) -> TypeGuard[type[AttrsType]]: ...


@overload
def is_attrs_class(obj: object) -> TypeGuard[AttrsType]:
...
def is_attrs_class(obj: object) -> TypeGuard[AttrsType]: ...


def is_attrs_class(obj: object) -> TypeGuard[type[AttrsType]]:
Expand All @@ -82,13 +78,11 @@ def is_attrs_class(obj: object) -> TypeGuard[type[AttrsType]]:


@overload
def is_pydantic_model(obj: type) -> TypeGuard[type[BaseModel]]:
...
def is_pydantic_model(obj: type) -> TypeGuard[type[BaseModel]]: ...


@overload
def is_pydantic_model(obj: object) -> TypeGuard[BaseModel]:
...
def is_pydantic_model(obj: object) -> TypeGuard[BaseModel]: ...


def is_pydantic_model(obj: object) -> TypeGuard[BaseModel]:
Expand All @@ -99,13 +93,11 @@ def is_pydantic_model(obj: object) -> TypeGuard[BaseModel]:


@overload
def is_msgspec_struct(obj: type) -> TypeGuard[type[msgspec.Struct]]:
...
def is_msgspec_struct(obj: type) -> TypeGuard[type[msgspec.Struct]]: ...


@overload
def is_msgspec_struct(obj: object) -> TypeGuard[msgspec.Struct]:
...
def is_msgspec_struct(obj: object) -> TypeGuard[msgspec.Struct]: ...


def is_msgspec_struct(obj: object) -> TypeGuard[msgspec.Struct]:
Expand Down
6 changes: 2 additions & 4 deletions src/psygnal/_evented_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def evented(
equality_operators: Optional[Dict[str, EqOperator]] = None,
warn_on_no_fields: bool = ...,
cache_on_instance: bool = ...,
) -> T:
...
) -> T: ...


@overload
Expand All @@ -44,8 +43,7 @@ def evented(
equality_operators: Optional[Dict[str, EqOperator]] = None,
warn_on_no_fields: bool = ...,
cache_on_instance: bool = ...,
) -> Callable[[T], T]:
...
) -> Callable[[T], T]: ...


def evented(
Expand Down
1 change: 1 addition & 0 deletions src/psygnal/_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
the args that were emitted.
"""

from __future__ import annotations

from typing import (
Expand Down
12 changes: 4 additions & 8 deletions src/psygnal/_group_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,13 @@ def __exit__(self, *args: Any) -> None:


@overload
def evented_setattr(signal_group_name: str, super_setattr: SetAttr) -> SetAttr:
...
def evented_setattr(signal_group_name: str, super_setattr: SetAttr) -> SetAttr: ...


@overload
def evented_setattr(
signal_group_name: str, super_setattr: Literal[None] | None = None
) -> Callable[[SetAttr], SetAttr]:
...
) -> Callable[[SetAttr], SetAttr]: ...


def evented_setattr(
Expand Down Expand Up @@ -412,12 +410,10 @@ def _do_patch_setattr(self, owner: type) -> None:
_instance_map: ClassVar[dict[int, SignalGroup]] = {}

@overload
def __get__(self, instance: None, owner: type) -> SignalGroupDescriptor:
...
def __get__(self, instance: None, owner: type) -> SignalGroupDescriptor: ...

@overload
def __get__(self, instance: object, owner: type) -> SignalGroup:
...
def __get__(self, instance: object, owner: type) -> SignalGroup: ...

def __get__(
self, instance: object, owner: type
Expand Down
6 changes: 3 additions & 3 deletions src/psygnal/_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class QueuedCallback(WeakCallback):
thread will be used.
"""

_GLOBAL_QUEUE: ClassVar[
collections.defaultdict[Thread, Queue[CbArgsTuple]]
] = DefaultDict(Queue)
_GLOBAL_QUEUE: ClassVar[collections.defaultdict[Thread, Queue[CbArgsTuple]]] = (
DefaultDict(Queue)
)

def __init__(
self,
Expand Down
22 changes: 10 additions & 12 deletions src/psygnal/_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,14 @@ def __set_name__(self, owner: type[Any], name: str) -> None:
self._name = name

@overload
def __get__(self, instance: None, owner: type[Any] | None = None) -> Signal:
... # pragma: no cover
def __get__(
self, instance: None, owner: type[Any] | None = None
) -> Signal: ... # pragma: no cover

@overload
def __get__(self, instance: Any, owner: type[Any] | None = None) -> SignalInstance:
... # pragma: no cover
def __get__(
self, instance: Any, owner: type[Any] | None = None
) -> SignalInstance: ... # pragma: no cover

def __get__(
self, instance: Any, owner: type[Any] | None = None
Expand Down Expand Up @@ -358,8 +360,7 @@ def connect(
unique: bool | str = ...,
max_args: int | None = None,
on_ref_error: RefErrorChoice = ...,
) -> Callable[[F], F]:
... # pragma: no cover
) -> Callable[[F], F]: ... # pragma: no cover

@overload
def connect(
Expand All @@ -372,8 +373,7 @@ def connect(
unique: bool | str = ...,
max_args: int | None = None,
on_ref_error: RefErrorChoice = ...,
) -> F:
... # pragma: no cover
) -> F: ... # pragma: no cover

def connect(
self,
Expand Down Expand Up @@ -841,8 +841,7 @@ def emit(
check_nargs: bool = False,
check_types: bool = False,
asynchronous: Literal[False] = False,
) -> None:
... # pragma: no cover
) -> None: ... # pragma: no cover

@overload
def emit(
Expand Down Expand Up @@ -948,8 +947,7 @@ def __call__(
check_nargs: bool = False,
check_types: bool = False,
asynchronous: Literal[False] = False,
) -> None:
... # pragma: no cover
) -> None: ... # pragma: no cover

@overload
def __call__(
Expand Down
2 changes: 2 additions & 0 deletions src/psygnal/_throttler.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ class _ThrottlerBase(Generic[P]):
) -> None: ...
def cancel(self) -> None:
"""Cancel any pending calls."""

def flush(self) -> None:
"""Force a call if there is one pending."""

def __call__(self, *args: P.args, **kwargs: P.kwargs) -> None: ...

class Throttler(_ThrottlerBase[P]):
Expand Down
3 changes: 1 addition & 2 deletions src/psygnal/_weak_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,7 @@ def dereference(self) -> partial | None:


class SupportsSetitem(Protocol):
def __setitem__(self, key: Any, value: Any) -> None:
...
def __setitem__(self, key: Any, value: Any) -> None: ...


class WeakSetitem(WeakCallback):
Expand Down
1 change: 1 addition & 0 deletions src/psygnal/containers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Containers backed by psygnal events."""

from typing import TYPE_CHECKING, Any

from ._evented_dict import EventedDict
Expand Down
1 change: 1 addition & 0 deletions src/psygnal/containers/_evented_dict.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Dict that emits events when altered."""

from __future__ import annotations

from typing import (
Expand Down
13 changes: 5 additions & 8 deletions src/psygnal/containers/_evented_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
MUST make sure that all the appropriate events are emitted. (Tests should
cover this in test_evented_list.py)
"""

from __future__ import annotations # pragma: no cover

from typing import (
Expand Down Expand Up @@ -141,25 +142,21 @@ def insert(self, index: int, value: _T) -> None:
self._post_insert(value)

@overload
def __getitem__(self, key: int) -> _T:
...
def __getitem__(self, key: int) -> _T: ...

@overload
def __getitem__(self, key: slice) -> Self:
...
def __getitem__(self, key: slice) -> Self: ...

def __getitem__(self, key: Index) -> _T | Self:
"""Return self[key]."""
result = self._data[key]
return self.__newlike__(result) if isinstance(result, list) else result

@overload
def __setitem__(self, key: int, value: _T) -> None:
...
def __setitem__(self, key: int, value: _T) -> None: ...

@overload
def __setitem__(self, key: slice, value: Iterable[_T]) -> None:
...
def __setitem__(self, key: slice, value: Iterable[_T]) -> None: ...

def __setitem__(self, key: Index, value: _T | Iterable[_T]) -> None:
"""Set self[key] to value."""
Expand Down
6 changes: 2 additions & 4 deletions src/psygnal/containers/_evented_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,12 @@ def __repr__(self) -> str:
def _pre_add_hook(self, item: _T) -> _T | BailType:
return item # pragma: no cover

def _post_add_hook(self, item: _T) -> None:
... # pragma: no cover
def _post_add_hook(self, item: _T) -> None: ... # pragma: no cover

def _pre_discard_hook(self, item: _T) -> _T | BailType:
return item # pragma: no cover

def _post_discard_hook(self, item: _T) -> None:
... # pragma: no cover
def _post_discard_hook(self, item: _T) -> None: ... # pragma: no cover

def _do_add(self, item: _T) -> None:
self._data.add(item)
Expand Down
1 change: 1 addition & 0 deletions src/psygnal/containers/_selectable_evented_list.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MutableSequence with a selection model."""

from typing import Any, Iterable, Tuple, TypeVar

from ._evented_list import EventedList, ListEvents
Expand Down
1 change: 1 addition & 0 deletions src/psygnal/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
psygnal is used in a Qt application, and you'd like to emit signals from a thread
but have their callbacks invoked in the main thread.
"""

from __future__ import annotations

from threading import Thread, current_thread
Expand Down
1 change: 1 addition & 0 deletions src/psygnal/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""These utilities may help when using signals and evented objects."""

from __future__ import annotations

from contextlib import contextmanager
Expand Down
15 changes: 5 additions & 10 deletions tests/test_evented_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ class Base:
if decorator:

@evented(equality_operators={"qux": operator.eq}) # just for test coverage
class Foo(Base):
...
class Foo(Base): ...

else:

Expand All @@ -102,8 +101,7 @@ class Base:
if decorator:

@evented
class Foo(Base):
...
class Foo(Base): ...

else:

Expand Down Expand Up @@ -135,8 +133,7 @@ class Base:
if decorator:

@evented
class Foo(Base):
...
class Foo(Base): ...

else:

Expand Down Expand Up @@ -164,8 +161,7 @@ class Base(BaseModel):
if decorator:

@evented(events_namespace="my_events")
class Foo(Base):
...
class Foo(Base): ...

else:

Expand Down Expand Up @@ -205,8 +201,7 @@ def test_no_signals_warn() -> None:
with pytest.warns(UserWarning, match="No mutable fields found on class"):

@evented
class Foo:
...
class Foo: ...

_ = Foo().events # type: ignore

Expand Down
Loading

0 comments on commit 80e1e73

Please sign in to comment.