Skip to content

Commit

Permalink
ci: switch formatter/linter to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
eginhard committed Apr 29, 2024
1 parent 17673ee commit 705e513
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 63 deletions.
Binary file removed .pre-commit-2.12.1.pyz
Binary file not shown.
29 changes: 8 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v2.3.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: 'https://github.com/psf/black'
rev: 20.8b1
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/isort
rev: 5.8.0
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
- repo: https://github.com/pycqa/pylint
rev: v2.8.2
hooks:
- id: pylint
13 changes: 3 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
.DEFAULT_GOAL := help
.PHONY: style lint install help
.PHONY: lint install help

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

target_dirs := tests coqpit


test: ## run tests.
coverage run -m pytest && coverage report --show-missing

style: ## update code style.
black ${target_dirs}
isort ${target_dirs}

lint: ## run pylint linter.
pylint ${target_dirs}
lint: ## run ruff format and lint
pre-commit run --all-files

install: ## install 👩‍✈️ Coqpit for development.
pip install -e .
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,5 @@ if __name__ == '__main__':
Install the pre-commit hook to automatically check your commits for style and hinting issues:

```bash
$ python .pre-commit-2.12.1.pyz install
pre-commit install
```
32 changes: 3 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,7 @@
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[flake8]
max-line-length=120

[tool.black]
[tool.ruff]
target-version = "py38"
line-length = 120
target-version = ['py38']
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| foo.py # also separately exclude a file named foo.py in
# the root of the project
)
'''

[tool.isort]
line_length = 120
profile = "black"
multi_line_output = 3
lint.extend-select = ["I", "UP", "B", "W", "A", "PLC", "PLE"]
4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pylint
black
ruff
pre-commit
pytest
coverage

0 comments on commit 705e513

Please sign in to comment.