From 81301d9420f24e41b65894870e42ed03ea660d9c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 21:02:54 +0000 Subject: [PATCH 1/2] ci: [pre-commit.ci] autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1) - [github.com/astral-sh/ruff-pre-commit: v0.1.9 → v0.2.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.9...v0.2.0) - [github.com/abravalheri/validate-pyproject: v0.15 → v0.16](https://github.com/abravalheri/validate-pyproject/compare/v0.15...v0.16) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70cfbb16..fbd34822 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,18 +12,18 @@ repos: - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.9 + rev: v0.2.0 hooks: - id: ruff args: ["--fix"] - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.15 + rev: v0.16 hooks: - id: validate-pyproject From 62b063ad42db80b252008bf7774708d3977dfe2b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 21:04:22 +0000 Subject: [PATCH 2/2] style: [pre-commit.ci] auto fixes [...] --- examples/qcollapsible.py | 1 + src/superqt/__init__.py | 1 + src/superqt/collapsible/_collapsible.py | 1 + src/superqt/fonticon/_qfont_icon.py | 6 +++--- src/superqt/sliders/_generic_slider.py | 1 + src/superqt/sliders/_labeled.py | 24 ++++++++-------------- src/superqt/utils/_qthreading.py | 27 +++++++++---------------- src/superqt/utils/_throttler.py | 13 +++++------- 8 files changed, 29 insertions(+), 45 deletions(-) diff --git a/examples/qcollapsible.py b/examples/qcollapsible.py index de73b5c2..78c7bc18 100644 --- a/examples/qcollapsible.py +++ b/examples/qcollapsible.py @@ -1,4 +1,5 @@ """Example for QCollapsible.""" + from qtpy.QtWidgets import QApplication, QLabel, QPushButton from superqt import QCollapsible diff --git a/src/superqt/__init__.py b/src/superqt/__init__.py index 8080da12..7da611a7 100644 --- a/src/superqt/__init__.py +++ b/src/superqt/__init__.py @@ -1,4 +1,5 @@ """superqt is a collection of Qt components for python.""" + from importlib.metadata import PackageNotFoundError, version from typing import TYPE_CHECKING, Any diff --git a/src/superqt/collapsible/_collapsible.py b/src/superqt/collapsible/_collapsible.py index 89d85510..92fb4e51 100644 --- a/src/superqt/collapsible/_collapsible.py +++ b/src/superqt/collapsible/_collapsible.py @@ -1,4 +1,5 @@ """A collapsible widget to hide and unhide child widgets.""" + from __future__ import annotations from qtpy.QtCore import ( diff --git a/src/superqt/fonticon/_qfont_icon.py b/src/superqt/fonticon/_qfont_icon.py index bc506942..48b4ae49 100644 --- a/src/superqt/fonticon/_qfont_icon.py +++ b/src/superqt/fonticon/_qfont_icon.py @@ -157,9 +157,9 @@ class _QFontIconEngine(QIconEngine): def __init__(self, options: _IconOptions): super().__init__() - self._opts: defaultdict[ - QIcon.State, dict[QIcon.Mode, _IconOptions | None] - ] = DefaultDict(dict) + self._opts: defaultdict[QIcon.State, dict[QIcon.Mode, _IconOptions | None]] = ( + DefaultDict(dict) + ) self._opts[QIcon.State.Off][QIcon.Mode.Normal] = options self.update_hash() diff --git a/src/superqt/sliders/_generic_slider.py b/src/superqt/sliders/_generic_slider.py index 7b35a924..2b8beade 100644 --- a/src/superqt/sliders/_generic_slider.py +++ b/src/superqt/sliders/_generic_slider.py @@ -19,6 +19,7 @@ scalar (with one handle per item), and it forms the basis of QRangeSlider. """ + import os import platform from typing import TypeVar diff --git a/src/superqt/sliders/_labeled.py b/src/superqt/sliders/_labeled.py index 38bb9d41..d33e285e 100644 --- a/src/superqt/sliders/_labeled.py +++ b/src/superqt/sliders/_labeled.py @@ -133,14 +133,12 @@ class QLabeledSlider(_SliderProxy, QAbstractSlider): _slider: QSlider @overload - def __init__(self, parent: QWidget | None = ...) -> None: - ... + def __init__(self, parent: QWidget | None = ...) -> None: ... @overload def __init__( self, orientation: Qt.Orientation, parent: QWidget | None = ... - ) -> None: - ... + ) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: parent, orientation = _handle_overloaded_slider_sig(args, kwargs) @@ -263,14 +261,12 @@ class QLabeledDoubleSlider(QLabeledSlider): _frangeChanged = Signal(float, float) @overload - def __init__(self, parent: QWidget | None = ...) -> None: - ... + def __init__(self, parent: QWidget | None = ...) -> None: ... @overload def __init__( self, orientation: Qt.Orientation, parent: QWidget | None = ... - ) -> None: - ... + ) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -300,14 +296,12 @@ class QLabeledRangeSlider(_SliderProxy, QAbstractSlider): _slider: QRangeSlider @overload - def __init__(self, parent: QWidget | None = ...) -> None: - ... + def __init__(self, parent: QWidget | None = ...) -> None: ... @overload def __init__( self, orientation: Qt.Orientation, parent: QWidget | None = ... - ) -> None: - ... + ) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: parent, orientation = _handle_overloaded_slider_sig(args, kwargs) @@ -545,14 +539,12 @@ class QLabeledDoubleRangeSlider(QLabeledRangeSlider): _frangeChanged = Signal(float, float) @overload - def __init__(self, parent: QWidget | None = ...) -> None: - ... + def __init__(self, parent: QWidget | None = ...) -> None: ... @overload def __init__( self, orientation: Qt.Orientation, parent: QWidget | None = ... - ) -> None: - ... + ) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) diff --git a/src/superqt/utils/_qthreading.py b/src/superqt/utils/_qthreading.py index c492f39d..a7b291bf 100644 --- a/src/superqt/utils/_qthreading.py +++ b/src/superqt/utils/_qthreading.py @@ -23,16 +23,13 @@ class SigInst(Generic[_T]): @staticmethod - def connect(slot: Callable[[_T], Any], type: type | None = ...) -> None: - ... + def connect(slot: Callable[[_T], Any], type: type | None = ...) -> None: ... @staticmethod - def disconnect(slot: Callable[[_T], Any] = ...) -> None: - ... + def disconnect(slot: Callable[[_T], Any] = ...) -> None: ... @staticmethod - def emit(*args: _T) -> None: - ... + def emit(*args: _T) -> None: ... from typing_extensions import Literal, ParamSpec @@ -499,8 +496,7 @@ def create_worker( _worker_class: type[GeneratorWorker] | type[FunctionWorker] | None = None, _ignore_errors: bool = False, **kwargs, -) -> GeneratorWorker[_Y, _S, _R]: - ... +) -> GeneratorWorker[_Y, _S, _R]: ... @overload @@ -512,8 +508,7 @@ def create_worker( _worker_class: type[GeneratorWorker] | type[FunctionWorker] | None = None, _ignore_errors: bool = False, **kwargs, -) -> FunctionWorker[_R]: - ... +) -> FunctionWorker[_R]: ... def create_worker( @@ -630,8 +625,7 @@ def thread_worker( connect: dict[str, Callable | Sequence[Callable]] | None = None, worker_class: type[WorkerBase] | None = None, ignore_errors: bool = False, -) -> Callable[_P, GeneratorWorker[_Y, _S, _R]]: - ... +) -> Callable[_P, GeneratorWorker[_Y, _S, _R]]: ... @overload @@ -641,8 +635,7 @@ def thread_worker( connect: dict[str, Callable | Sequence[Callable]] | None = None, worker_class: type[WorkerBase] | None = None, ignore_errors: bool = False, -) -> Callable[_P, FunctionWorker[_R]]: - ... +) -> Callable[_P, FunctionWorker[_R]]: ... @overload @@ -652,8 +645,7 @@ def thread_worker( connect: dict[str, Callable | Sequence[Callable]] | None = None, worker_class: type[WorkerBase] | None = None, ignore_errors: bool = False, -) -> Callable[[Callable], Callable[_P, FunctionWorker | GeneratorWorker]]: - ... +) -> Callable[[Callable], Callable[_P, FunctionWorker | GeneratorWorker]]: ... def thread_worker( @@ -790,8 +782,7 @@ def worker_function(*args, **kwargs): class WorkerProtocol(QObject): finished: Signal - def work(self) -> None: - ... + def work(self) -> None: ... def new_worker_qthread( diff --git a/src/superqt/utils/_throttler.py b/src/superqt/utils/_throttler.py index 9e5d939c..b63f0db2 100644 --- a/src/superqt/utils/_throttler.py +++ b/src/superqt/utils/_throttler.py @@ -26,6 +26,7 @@ SOFTWARE. """ + from __future__ import annotations from concurrent.futures import Future @@ -301,8 +302,7 @@ def qthrottled( leading: bool = True, timer_type: Qt.TimerType = Qt.TimerType.PreciseTimer, parent: QObject | None = None, -) -> ThrottledCallable[P, R]: - ... +) -> ThrottledCallable[P, R]: ... @overload @@ -312,8 +312,7 @@ def qthrottled( leading: bool = True, timer_type: Qt.TimerType = Qt.TimerType.PreciseTimer, parent: QObject | None = None, -) -> Callable[[Callable[P, R]], ThrottledCallable[P, R]]: - ... +) -> Callable[[Callable[P, R]], ThrottledCallable[P, R]]: ... def qthrottled( @@ -364,8 +363,7 @@ def qdebounced( leading: bool = False, timer_type: Qt.TimerType = Qt.TimerType.PreciseTimer, parent: QObject | None = None, -) -> ThrottledCallable[P, R]: - ... +) -> ThrottledCallable[P, R]: ... @overload @@ -375,8 +373,7 @@ def qdebounced( leading: bool = False, timer_type: Qt.TimerType = Qt.TimerType.PreciseTimer, parent: QObject | None = None, -) -> Callable[[Callable[P, R]], ThrottledCallable[P, R]]: - ... +) -> Callable[[Callable[P, R]], ThrottledCallable[P, R]]: ... def qdebounced(