ci: [pre-commit.ci] autoupdate (#146)

* ci: [pre-commit.ci] autoupdate

updates:
- [github.com/charliermarsh/ruff-pre-commit: v0.0.149 → v0.0.161](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.149...v0.0.161)

* fix: fix linting

* style: add docstyle

* style: formatting

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Talley Lambert <talley.lambert@gmail.com>
This commit is contained in:
pre-commit-ci[bot]
2022-12-06 12:02:27 -05:00
committed by GitHub
parent 2cebc868a8
commit 6ce87d44a6
12 changed files with 33 additions and 27 deletions

View File

@@ -17,7 +17,7 @@ repos:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.149
rev: v0.0.165
hooks:
- id: ruff
args: ["--fix"]

View File

@@ -37,7 +37,7 @@ def define_env(env: "MacrosPlugin"):
)
src = src.replace("app.exec_()", "")
exec(src)
exec(src) # noqa: S102
_grab(dest, width)
return (
f"![{page.title}](../{dest.parent.name}/{dest.name})"

View File

@@ -1,4 +1,4 @@
"""Example for QCollapsible"""
"""Example for QCollapsible."""
from qtpy.QtWidgets import QApplication, QLabel, QPushButton
from superqt import QCollapsible

View File

@@ -1,4 +1,4 @@
"""Adapted for python from the KDToolBox
"""Adapted for python from the KDToolBox.
https://github.com/KDAB/KDToolBox/tree/master/qt/KDSignalThrottler

View File

@@ -101,16 +101,15 @@ src = ["src","tests"]
extend-select = [
"E", # style errors
"F", # flakes
# "D", # pydocstyle
"I001", # isort
"D", # pydocstyle
"I", # isort
"U", # pyupgrade
# "N", # pep8-naming
# "S", # bandit
"S", # bandit
"C", # flake8-comprehensions
"B", # flake8-bugbear
"A001", # flake8-builtins
"RUF", # ruff-specific rules
"M001", # Unused noqa directive
]
extend-ignore = [
"D100", # Missing docstring in public module
@@ -125,9 +124,9 @@ extend-ignore = [
[tool.ruff.per-file-ignores]
"tests/*.py" = ["D"]
"tests/*.py" = ["D", "S101"]
"examples/demo_widget.py" = ["E501"]
"examples/*.py" = ["B"]
"examples/*.py" = ["B", "D"]
# https://docs.pytest.org/en/6.2.x/customize.html
[tool.pytest.ini_options]

View File

@@ -128,7 +128,7 @@ class QCollapsible(QFrame):
self._animation.setDuration(msecs)
def setEasingCurve(self, easing: QEasingCurve) -> None:
"""Set the easing curve for the collapse/expand animation"""
"""Set the easing curve for the collapse/expand animation."""
self._animation.setEasingCurve(easing)
def addWidget(self, widget: QWidget) -> None:
@@ -142,11 +142,11 @@ class QCollapsible(QFrame):
widget.removeEventFilter(self)
def expand(self, animate: bool = True) -> None:
"""Expand (show) the collapsible section"""
"""Expand (show) the collapsible section."""
self._expand_collapse(QPropertyAnimation.Direction.Forward, animate)
def collapse(self, animate: bool = True) -> None:
"""Collapse (hide) the collapsible section"""
"""Collapse (hide) the collapsible section."""
self._expand_collapse(QPropertyAnimation.Direction.Backward, animate)
def isExpanded(self) -> bool:
@@ -154,7 +154,7 @@ class QCollapsible(QFrame):
return self._toggle_btn.isChecked()
def setLocked(self, locked: bool = True) -> None:
"""Set whether collapse/expand is disabled"""
"""Set whether collapse/expand is disabled."""
self._locked = locked
self._toggle_btn.setCheckable(not locked)
@@ -172,7 +172,8 @@ class QCollapsible(QFrame):
An emit flag is included so that the toggle signal is only called once (it
was being emitted a few times via eventFilter when the widget was expanding
previously)."""
previously).
"""
if self._locked:
return

View File

@@ -72,9 +72,10 @@ class IconFont(metaclass=IconFontMeta):
def namespace2font(namespace: Union[Mapping, Type], name: str) -> Type[IconFont]:
"""Convenience to convert a namespace (class, module, dict) into an IconFont."""
if isinstance(namespace, type):
assert isinstance(
getattr(namespace, FONTFILE_ATTR), str
), "Not a valid font type"
if not isinstance(getattr(namespace, FONTFILE_ATTR), str):
raise TypeError(
f"Invalid Font: must declare {FONTFILE_ATTR!r} attribute or classmethod"
)
return namespace
elif hasattr(namespace, "__dict__"):
ns = dict(namespace.__dict__)

View File

@@ -23,7 +23,8 @@ from qtpy.QtGui import (
from qtpy.QtWidgets import QApplication, QStyleOption, QWidget
from typing_extensions import TypedDict
from ..utils import QMessageHandler
from superqt.utils import QMessageHandler
from ._animations import Animation
@@ -45,8 +46,8 @@ ValidColor = Union[
int,
str,
Qt.GlobalColor,
Tuple[int, int, int, int], # noqa: U006
Tuple[int, int, int], # noqa: U006
Tuple[int, int, int, int],
Tuple[int, int, int],
None,
]
@@ -571,5 +572,6 @@ def _ensure_identifier(name: str) -> str:
# replace dashes and spaces with underscores
name = name.replace("-", "_").replace(" ", "_")
assert str.isidentifier(name), f"Could not canonicalize name: {name}"
if not str.isidentifier(name):
raise ValueError(f"Could not canonicalize name: {name!r}. (not an identifier)")
return name

View File

@@ -17,7 +17,8 @@ from qtpy.QtWidgets import (
QWidget,
)
from ..utils import signals_blocked
from superqt.utils import signals_blocked
from ._sliders import QDoubleRangeSlider, QDoubleSlider, QRangeSlider

View File

@@ -11,7 +11,7 @@ except ImportError as e:
from qtpy.QtCore import Signal
from qtpy.QtWidgets import QComboBox, QDoubleSpinBox, QHBoxLayout, QSizePolicy, QWidget
from ..utils import signals_blocked
from superqt.utils import signals_blocked
if TYPE_CHECKING:
from decimal import Decimal
@@ -78,7 +78,10 @@ class QQuantity(QWidget):
if ureg is None:
ureg = value._REGISTRY if isinstance(value, Quantity) else UREG
else:
assert isinstance(ureg, UnitRegistry)
if not isinstance(ureg, UnitRegistry):
raise TypeError(
f"ureg must be a pint.UnitRegistry, not {type(ureg).__name__}"
)
self._ureg = ureg
self._value: Quantity = self._ureg.Quantity(value, units=units)

View File

@@ -6,6 +6,7 @@ from pygments.lexers import find_lexer_class, get_lexer_by_name
from pygments.util import ClassNotFound
from qtpy import QtGui
# inspired by https://github.com/Vector35/snippets/blob/master/QCodeEditor.py
# (MIT license) and
# https://pygments.org/docs/formatterdevelopment/#html-3-2-formatter

View File

@@ -133,8 +133,6 @@ class GenericSignalThrottler(QObject):
elif self._kind is Kind.Debouncer:
self._timer.start() # restart
assert self._timer.isActive()
def cancel(self) -> None:
"""Cancel any pending emissions."""
self._hasPendingEmission = False