diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8364d7ce..19bcc27c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,19 +7,19 @@ exclude: .asv repos: - repo: https://github.com/crate-ci/typos - rev: typos-dict-v0.11.35 + rev: typos-dict-v0.11.37 hooks: - id: typos - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.3 + rev: v0.8.1 hooks: - id: ruff args: [--fix, --unsafe-fixes] - id: ruff-format - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.22 + rev: v0.23 hooks: - id: validate-pyproject diff --git a/src/psygnal/__init__.py b/src/psygnal/__init__.py index 8bceb9e7..8ffd9483 100644 --- a/src/psygnal/__init__.py +++ b/src/psygnal/__init__.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any if TYPE_CHECKING: - from ._evented_model import EventedModel # noqa: TCH004 + from ._evented_model import EventedModel # noqa: TC004 try: @@ -19,20 +19,20 @@ __email__ = "talley.lambert@gmail.com" __all__ = [ - "__version__", - "_compiled", - "debounced", "EmissionInfo", - "emit_queued", "EmitLoopError", - "evented", "EventedModel", - "get_evented_namespace", - "is_evented", "Signal", "SignalGroup", "SignalGroupDescriptor", "SignalInstance", + "__version__", + "_compiled", + "debounced", + "emit_queued", + "evented", + "get_evented_namespace", + "is_evented", "throttled", ] diff --git a/src/psygnal/_evented_model.py b/src/psygnal/_evented_model.py index 427c0384..82bb78f1 100644 --- a/src/psygnal/_evented_model.py +++ b/src/psygnal/_evented_model.py @@ -1,6 +1,6 @@ import sys import warnings -from collections.abc import Iterator, Mapping +from collections.abc import Iterator from contextlib import contextmanager, suppress from typing import ( TYPE_CHECKING, diff --git a/src/psygnal/_group.py b/src/psygnal/_group.py index 59154637..fa1d77c6 100644 --- a/src/psygnal/_group.py +++ b/src/psygnal/_group.py @@ -159,7 +159,7 @@ def block(self, exclude: Iterable[str | SignalInstance] = ()) -> None: """Block this signal and all emitters from emitting.""" super().block() for name, sig in self._signals.items(): - if exclude and sig in exclude or name in exclude: + if (exclude and sig in exclude) or name in exclude: continue self._sig_was_blocked[name] = sig._is_blocked sig.block() diff --git a/src/psygnal/_group_descriptor.py b/src/psygnal/_group_descriptor.py index 73b92255..59c24804 100644 --- a/src/psygnal/_group_descriptor.py +++ b/src/psygnal/_group_descriptor.py @@ -33,7 +33,7 @@ EqOperator: TypeAlias = Callable[[Any, Any], bool] FieldAliasFunc: TypeAlias = Callable[[str], Optional[str]] -__all__ = ["is_evented", "get_evented_namespace", "SignalGroupDescriptor"] +__all__ = ["SignalGroupDescriptor", "get_evented_namespace", "is_evented"] T = TypeVar("T", bound=type) diff --git a/src/psygnal/_weak_callback.py b/src/psygnal/_weak_callback.py index 332ccfd3..541c414a 100644 --- a/src/psygnal/_weak_callback.py +++ b/src/psygnal/_weak_callback.py @@ -24,7 +24,7 @@ RefErrorChoice: TypeAlias = Literal["raise", "warn", "ignore"] -__all__ = ["weak_callback", "WeakCallback"] +__all__ = ["WeakCallback", "weak_callback"] _T = TypeVar("_T") _R = TypeVar("_R") # return type of cb diff --git a/src/psygnal/utils.py b/src/psygnal/utils.py index 69a73147..e37a290f 100644 --- a/src/psygnal/utils.py +++ b/src/psygnal/utils.py @@ -14,7 +14,7 @@ if TYPE_CHECKING: from collections.abc import Generator, Iterator -__all__ = ["monitor_events", "iter_signal_instances"] +__all__ = ["iter_signal_instances", "monitor_events"] def _default_event_monitor(info: EmissionInfo) -> None: diff --git a/tests/test_evented_model.py b/tests/test_evented_model.py index 12b41773..693a8b40 100644 --- a/tests/test_evented_model.py +++ b/tests/test_evented_model.py @@ -914,7 +914,7 @@ def d(self, value): ], ) def test_evented_model_reemission(mode: Union[str, dict]) -> None: - err = mode == "err" or isinstance(mode, dict) and "err" in mode.values() + err = mode == "err" or (isinstance(mode, dict) and "err" in mode.values()) with ( pytest.raises(ValueError, match="Invalid reemission") if err else nullcontext() ): diff --git a/tests/test_psygnal.py b/tests/test_psygnal.py index bae11e33..839d3057 100644 --- a/tests/test_psygnal.py +++ b/tests/test_psygnal.py @@ -554,7 +554,7 @@ def test_connect_validation(func_name, sig_name, mode, typed): signal: SignalInstance = getattr(e, sig_name) bad_count = COUNT_INCOMPATIBLE[sig_name] bad_sig = SIG_INCOMPATIBLE[sig_name] - if func_name in bad_count or check_types and func_name in bad_sig: + if func_name in bad_count or (check_types and func_name in bad_sig): with pytest.raises(ValueError) as er: signal.connect(func, check_types=check_types) assert "Accepted signature:" in str(er)