Skip to content

Commit

Permalink
Use ruff as Python code formatter and linter
Browse files Browse the repository at this point in the history
Use `ruff` to replace:

* `autoflake`
* `black`
* `isort`
* `flake8`

Also reorganize the `pre-commit` hooks in a more logical order.
  • Loading branch information
fabcor-maxiv committed Feb 14, 2025
1 parent a10a4e8 commit 6f9518f
Show file tree
Hide file tree
Showing 7 changed files with 635 additions and 88 deletions.
12 changes: 0 additions & 12 deletions .flake8

This file was deleted.

4 changes: 0 additions & 4 deletions .isort.cfg

This file was deleted.

73 changes: 27 additions & 46 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,40 @@

repos:


- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-case-conflict
- id: check-merge-conflict
# exclude files where underlines are not distinguishable from merge conflicts
exclude: /README\.rst$|^docs/.*\.rst$
- id: check-symlinks
- id: check-xml
- id: check-yaml
exclude: ^.drone\.yml|meta.yaml
- id: mixed-line-ending
args: ["--fix=lf"]


- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args:
- --strict


- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.6
hooks:
- id: ruff
args: [--fix]
- id: ruff-format


- repo: https://github.com/python-poetry/poetry
rev: 2.0.1
hooks:
Expand All @@ -38,51 +65,5 @@ repos:
hooks:
- id: poetry-export

- repo: https://github.com/myint/autoflake
rev: v2.3.1
hooks:
- id: autoflake
name: Autoflake
args:
- --expand-star-imports
- --ignore-init-module-imports
- --in-place
- --remove-duplicate-keys
- --ignore-pass-after-docstring

- repo: https://github.com/pycqa/isort
rev: 6.0.0
hooks:
- id: isort

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.1.0
hooks:
- id: black
name: Black

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-case-conflict
- id: check-merge-conflict
# exclude files where underlines are not distinguishable from merge conflicts
exclude: /README\.rst$|^docs/.*\.rst$
- id: check-symlinks
- id: check-xml
- id: check-yaml
exclude: ^.drone\.yml|meta.yaml
- id: mixed-line-ending
args: ["--fix=lf"]

- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
name: Flake8
exclude: (ui/|test/)


...
25 changes: 0 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,6 @@ sphinx = "<7.2"
sphinx-last-updated-by-git = "^0.3.7"
sphinxcontrib-httpdomain = "^1.8.1"

[tool.black]
line-length = 88
required-version = "25"
target-version = [
"py310",
"py311",
]
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| test
| ui
| docs
)/
'''

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Loading

0 comments on commit 6f9518f

Please sign in to comment.