diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47fbe92f..517bdeb0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,23 +4,17 @@ ci: autoupdate_commit_msg: "ci: [pre-commit.ci] autoupdate" repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + - repo: https://github.com/crate-ci/typos + rev: v1.19.0 hooks: - - id: check-docstring-first - - id: end-of-file-fixer - - id: trailing-whitespace + - id: typos - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.0 + rev: v0.3.0 hooks: - id: ruff args: [--fix] - - - repo: https://github.com/psf/black - rev: 24.1.1 - hooks: - - id: black + - id: ruff-format - repo: https://github.com/abravalheri/validate-pyproject rev: v0.16 diff --git a/pyproject.toml b/pyproject.toml index e104578f..fd56e676 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ pyqt5 = ["PyQt5"] pyqt6 = ["PyQt6"] pyside2 = ["PySide2"] pyside6 = ["PySide6"] -dev = ["black", "isort", "mda-simulator", "mypy", "pre-commit", "ruff"] +dev = ["isort", "mda-simulator", "mypy", "pre-commit", "ruff"] [project.urls] Source = "https://github.com/pymmcore-plus/napari-micromanager" @@ -77,34 +77,37 @@ include = ["/src", "/tests"] [tool.ruff] line-length = 88 target-version = "py38" + +[tool.ruff.lint] +pydocstyle = { convention = "numpy" } select = [ "E", # style errors + "W", # warnings "F", # flakes "D", # pydocstyle + "D417", # Missing argument descriptions in Docstrings "I", # isort "UP", # pyupgrade "S", # bandit - "C", # flake8-comprehensions + "C4", # flake8-comprehensions "B", # flake8-bugbear "A001", # flake8-builtins "RUF", # ruff-specific rules "TCH", # flake8-type-checking + "TID", # flake8-tidy-imports ] ignore = [ "D100", # Missing docstring in public module - "D107", # Missing docstring in __init__ - "D203", # 1 blank line required before class docstring - "D212", # Multi-line docstring summary should start at the first line - "D213", # Multi-line docstring summary should start at the second line - "D400", # First line should end with a period - "D413", # Missing blank line after last section - "D416", # Section name should end with a colon - "C901", # Function is too complex + "D401", # First line should end with a period ] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "tests/*.py" = ["D", "S"] +# https://docs.astral.sh/ruff/formatter/ +[tool.ruff.format] +docstring-code-format = true + # https://docs.pytest.org/en/6.2.x/customize.html [tool.pytest.ini_options] minversion = "6.0" @@ -116,7 +119,7 @@ filterwarnings = [ "ignore: data with shape:DeprecationWarning:", # for napari "ignore:`np.bool8` is a deprecated alias::skimage", "ignore:Jupyter is migrating its paths to use standard platformdirs:", - "ignore:\\nPyarrow will become a required dependency" + "ignore:\\nPyarrow will become a required dependency", ] # https://mypy.readthedocs.io/en/stable/config_file.html diff --git a/src/napari_micromanager/_mda_handler.py b/src/napari_micromanager/_mda_handler.py index ece8bd75..b298f307 100644 --- a/src/napari_micromanager/_mda_handler.py +++ b/src/napari_micromanager/_mda_handler.py @@ -191,7 +191,7 @@ def _watch_mda( time.sleep(0.1) def _on_mda_frame(self, image: np.ndarray, event: MDAEvent) -> None: - """Called on the `frameReady` event from the core.""" # noqa: D401 + """Called on the `frameReady` event from the core.""" self._deck.append((image, event)) def _process_frame( diff --git a/src/napari_micromanager/main_window.py b/src/napari_micromanager/main_window.py index 0c59458f..4d3ba523 100644 --- a/src/napari_micromanager/main_window.py +++ b/src/napari_micromanager/main_window.py @@ -22,6 +22,7 @@ # this is very verbose logging.getLogger("napari.loader").setLevel(logging.WARNING) +logging.getLogger("in_n_out").setLevel(logging.WARNING) class MainWindow(MicroManagerToolbar): diff --git a/tests/test_main.py b/tests/test_main.py index de4b1936..5cae6d6b 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -11,7 +11,7 @@ [ [], ["--config", str(Path(__file__).parent / "test_config.cfg")], - ["-c", "nonexistant"], + ["-c", "nonexistent"], ], ) def test_cli_main(argv: list) -> None: @@ -20,7 +20,7 @@ def test_cli_main(argv: list) -> None: with patch("napari.run") as mock_run: with patch("qtpy.QtWidgets.QMainWindow.show") as mock_show: - if "nonexistant" in argv: + if "nonexistent" in argv: with pytest.warns(): main(argv) else: