From 09c76a0bfabaa029bf75893afc86b353cc6e3d26 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 6 Apr 2023 19:51:39 -0400 Subject: [PATCH] ci: [pre-commit.ci] autoupdate (#156) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: [pre-commit.ci] autoupdate updates: - [github.com/psf/black: 23.1.0 → 23.3.0](https://github.com/psf/black/compare/23.1.0...23.3.0) - [github.com/charliermarsh/ruff-pre-commit: v0.0.254 → v0.0.260](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.254...v0.0.260) - [github.com/abravalheri/validate-pyproject: v0.12.1 → v0.12.2](https://github.com/abravalheri/validate-pyproject/compare/v0.12.1...v0.12.2) * style: [pre-commit.ci] auto fixes [...] * fix: fix precommit --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Talley Lambert --- .pre-commit-config.yaml | 6 +++--- src/superqt/fonticon/__init__.py | 4 ++-- src/superqt/fonticon/_qfont_icon.py | 9 +++++---- src/superqt/qtcompat/__init__.py | 3 ++- src/superqt/utils/_qthreading.py | 1 + tests/test_threadworker.py | 6 +++--- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6ead559..5275492 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.1.0 + rev: 23.3.0 hooks: - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.254 + rev: v0.0.260 hooks: - id: ruff args: ["--fix"] - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.12.1 + rev: v0.12.2 hooks: - id: validate-pyproject diff --git a/src/superqt/fonticon/__init__.py b/src/superqt/fonticon/__init__.py index 39e47a1..70ef5ac 100644 --- a/src/superqt/fonticon/__init__.py +++ b/src/superqt/fonticon/__init__.py @@ -137,7 +137,7 @@ def icon( >>> btn.setIconSize(QSize(256, 256)) >>> btn.show() - """ # noqa: E501 + """ return _QFIS.instance().icon( glyph_key, scale_factor=scale_factor, @@ -218,7 +218,7 @@ def addFont( Tuple[str, str], optional font-family and font-style for the file just registered, or `None` if something goes wrong. - """ # noqa: E501 + """ return _QFIS.instance().addFont(filepath, prefix, charmap) diff --git a/src/superqt/fonticon/_qfont_icon.py b/src/superqt/fonticon/_qfont_icon.py index 15328a1..5ea96cf 100644 --- a/src/superqt/fonticon/_qfont_icon.py +++ b/src/superqt/fonticon/_qfont_icon.py @@ -456,7 +456,7 @@ class QFontIconStore(QObject): something goes wrong. """ if prefix in cls._LOADED_KEYS: - warnings.warn(f"Prefix {prefix} already loaded") + warnings.warn(f"Prefix {prefix} already loaded", stacklevel=2) return None if not Path(filepath).exists(): @@ -466,12 +466,12 @@ class QFontIconStore(QObject): fontId = QFontDatabase.addApplicationFont(str(Path(filepath).absolute())) if fontId < 0: # pragma: no cover - warnings.warn(f"Cannot load font file: {filepath}") + warnings.warn(f"Cannot load font file: {filepath}", stacklevel=2) return None families = QFontDatabase.applicationFontFamilies(fontId) if not families: # pragma: no cover - warnings.warn(f"Font file is empty!: {filepath}") + warnings.warn(f"Font file is empty!: {filepath}", stacklevel=2) return None family: str = families[0] @@ -487,7 +487,8 @@ class QFontIconStore(QObject): if not QFd.isSmoothlyScalable(family, style): # pragma: no cover warnings.warn( f"Registered font {family} ({style}) is not smoothly scalable. " - "Icons may not look attractive." + "Icons may not look attractive.", + stacklevel=2, ) cls._LOADED_KEYS[prefix] = (family, style) diff --git a/src/superqt/qtcompat/__init__.py b/src/superqt/qtcompat/__init__.py index 69413d9..90b46f0 100644 --- a/src/superqt/qtcompat/__init__.py +++ b/src/superqt/qtcompat/__init__.py @@ -6,7 +6,8 @@ from qtpy import * # noqa warnings.warn( "The superqt.qtcompat module is deprecated as of v0.3.0. " - "Please import from `qtpy` instead." + "Please import from `qtpy` instead.", + stacklevel=2, ) diff --git a/src/superqt/utils/_qthreading.py b/src/superqt/utils/_qthreading.py index 4559012..1250eee 100644 --- a/src/superqt/utils/_qthreading.py +++ b/src/superqt/utils/_qthreading.py @@ -184,6 +184,7 @@ class WorkerBase(QRunnable, Generic[_R]): warnings.warn( f"RuntimeError in aborted thread: {result}", RuntimeWarning, + stacklevel=2, ) return else: diff --git a/tests/test_threadworker.py b/tests/test_threadworker.py index 2c9b52d..4e5e3c9 100644 --- a/tests/test_threadworker.py +++ b/tests/test_threadworker.py @@ -98,9 +98,9 @@ def test_thread_warns(qtbot): @qthreading.thread_worker(connect={"warned": check_warning}, start_thread=False) def func(): yield 1 - warnings.warn("hey!") + warnings.warn("hey!") # noqa: B028 yield 3 - warnings.warn("hey!") + warnings.warn("hey!") # noqa: B028 return 1 wrkr = func() @@ -236,7 +236,7 @@ def test_worker_base_attribute(qapp): assert obj.returned is not None assert obj.errored is not None with pytest.raises(AttributeError): - obj.aa + _ = obj.aa def test_abort_does_not_return(qtbot):