diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f760ce1..2779172 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,19 +8,16 @@ repos: - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files -- repo: https://github.com/psf/black - rev: 24.8.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.3 hooks: - - id: black + - id: ruff + args: [ --fix ] + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.13.0 hooks: - id: mypy -- repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - args: [--profile=black] - repo: https://github.com/pre-commit/mirrors-clang-format rev: v19.1.5 hooks: diff --git a/docs/gen_config.py b/docs/gen_config.py index dedebaf..551809b 100644 --- a/docs/gen_config.py +++ b/docs/gen_config.py @@ -50,7 +50,7 @@ if arg.doc is not None: arg_text += arg.doc if arg.default is not None: - if arg.type == bool: + if arg.type is bool: default = arg.default == "yes" else: default = arg.type(arg.default) diff --git a/py/soundswallower/__init__.py b/py/soundswallower/__init__.py index 51b47cf..4944d94 100644 --- a/py/soundswallower/__init__.py +++ b/py/soundswallower/__init__.py @@ -21,11 +21,7 @@ import wave from typing import Optional, Tuple -from ._soundswallower import Config # noqa: F401 -from ._soundswallower import Decoder # noqa: F401 -from ._soundswallower import Endpointer # noqa: F401 -from ._soundswallower import FsgModel # noqa: F401 -from ._soundswallower import Vad # noqa: F401 +from ._soundswallower import Config, Decoder, Endpointer, FsgModel, Vad def get_model_path(subpath: Optional[str] = None) -> str: @@ -91,14 +87,14 @@ def get_audio_data(input_file: str) -> Tuple[bytes, Optional[int]]: Hyp.prob.__doc__ = "Posterior probability of hypothesis (often 1.0, sorry)." __all__ = [ + "Arg", "Config", "Decoder", - "FsgModel", - "Vad", "Endpointer", - "Arg", - "Seg", + "FsgModel", "Hyp", - "get_model_path", + "Seg", + "Vad", "get_audio_data", + "get_model_path", ] diff --git a/pyproject.toml b/pyproject.toml index d3da66c..93b4323 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,12 +33,11 @@ classifiers = [ [project.optional-dependencies] dev = [ - "pytest", + "mypy==1.13.0", "numpy", "pre-commit", - "black==24.8.0", - "isort", - "mypy==1.13.0", + "pytest", + "ruff", ] [project.urls] @@ -73,13 +72,23 @@ skip = [ [tool.cibuildwheel.macos] archs = ["x86_64", "universal2", "arm64"] -[tool.isort] -known_first_party = ["soundswallower"] -profile = "black" +[tool.ruff.lint] +select = [ + "B", # flake8-bugbear + "BLE", # flake8-blind-except + "C4", # flake8-comprehensions + "C90", # mccabe code complexity + "E", # pycodestyle errors + "F", # pyflakes + "I", # isort + "PL", # pylint + "RUF", # Ruff-specific rules + "W", # pycodestyle whitespace +] +fixable = ["I"] -[tool.flake8] -extend-ignore = "E203" -max-line-length = "88" +[tool.ruff.lint.isort] +known-first-party = ["soundswallower"] [tool.scikit-build] metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"