From b2dfbf6d7a05b42c97375e6c34b6ce6a0356b449 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Fri, 27 Jan 2023 10:42:55 +0100 Subject: [PATCH] changing linter tooling to "ruff" --- .pre-commit-config.yaml | 27 +++++-------------- Makefile | 5 +--- pyproject.toml | 59 ++++++++++++++++++++++++++++++----------- 3 files changed, 51 insertions(+), 40 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 372083c..dd24948 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,33 +11,18 @@ repos: - id: detect-private-key - repo: local hooks: - - id: isort-project - name: isort project - entry: isort -rc src - language: system - pass_filenames: false - - id: isort-test - name: isort test - entry: isort -rc tests - language: system - pass_filenames: false - id: black - name: black + name: Autoformatting code with "black" entry: black src tests language: system pass_filenames: false - - id: flake8 - name: flake8 project - entry: flake8 --ignore E231,W503 src - language: system - pass_filenames: false - - id: flake8 - name: flake8 test - entry: flake8 --ignore S101,W503 tests + - id: ruff + name: Linting code with "ruff" + entry: ruff src tests language: system pass_filenames: false - id: pytest - name: pytest + name: Testing the project with "pytest" entry: pytest tests - pass_filenames: false language: system + pass_filenames: false diff --git a/Makefile b/Makefile index be53078..a9286df 100644 --- a/Makefile +++ b/Makefile @@ -54,11 +54,8 @@ clean-test: ## remove test and coverage artifacts rm -fr htmlcov/ lint: ## reformat with black and check style with flake8 - isort src - isort tests black src tests - flake8 --ignore E231,W503,E402 src - flake8 --ignore S101,W503 tests + ruff src tests test: lint ## run tests quickly, stop on first error pytest tests -x -l --last-failed --disable-warnings -m "not functional" diff --git a/pyproject.toml b/pyproject.toml index c295a30..b756b85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,18 +48,25 @@ test = [ ] dev = [ "black", - "flake8", - "flake8-comprehensions", - "flake8-bandit", - "isort >= 5.0.0", "keyring", "pre-commit", + "ruff", ] docs = [ "mkdocs", "mkdocstrings[python]", ] + +[tool.pytest.ini_options] +markers = [ + "functional: marks tests as functional (deselect with '-m \"not functional\"')", +] +addopts = [ + "--strict-markers", +] + + [tool.black] line-length = 79 target-version = ['py39', 'py310'] @@ -74,16 +81,38 @@ extend-exclude = ''' ^/.dist ''' -[tool.isort] -line_length=79 -multi_line_output=3 -length_sort="True" -include_trailing_comma="True" +[tool.ruff] +# see https://github.com/charliermarsh/ruff +select = ["ALL"] +ignore = [ + # ignored for now, should be activated in the future + # docstrings + "D", + # flake8-annotations + "ANN", + # flake8-type-checking + "TCH", -[tool.pytest.ini_options] -markers = [ - "functional: marks tests as functional (deselect with '-m \"not functional\"')", -] -addopts = [ - "--strict-markers", + # ignored, "black" will handle this + # flake8-commas + "COM", + + # ignored, due to Windows / WSL2 setup + # flake8-executable + "EXE", + + # project specific ignores + # flake8-import-conventions + "ICN", ] +fixable = ["I"] +fix = true +line-length=79 +target-version = "py38" + +[tool.ruff.per-file-ignores] +# see https://github.com/charliermarsh/ruff +"tests/*" = ["FBT003", "INP001", "PLR2004", "S101"] + +[tool.ruff.pydocstyle] +convention = "pep257" # Accepts: "google", "numpy", or "pep257". \ No newline at end of file