Skip to content

Commit

Permalink
style: replace isort with ruff check and black with ruff format (#75)
Browse files Browse the repository at this point in the history
* Replace isort with ruff check and black with ruff format

* Remove # noqa: F401

* Add RUF rules

* Fix only isort and ruff format
  • Loading branch information
cclauss authored Dec 16, 2024
1 parent 3027797 commit 43defa4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
13 changes: 5 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/gen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 6 additions & 10 deletions py/soundswallower/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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",
]
29 changes: 19 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 43defa4

Please sign in to comment.