diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..28261a8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,36 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: https://github.com/pycqa/flake8 + rev: 7.1.1 + hooks: + - id: flake8 + additional_dependencies: + - flake8-isort + args: [--max-line-length=88] + + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + args: ['--profile=black'] + files: \.py$ + + - repo: https://github.com/psf/black + rev: 24.8.0 + hooks: + - id: black + language_version: python3.8 + + - repo: https://github.com/pycqa/autoflake + rev: v1.6.0 + hooks: + - id: autoflake + name: autoflake (remove unused imports and variables) + args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variables'] + types: [python] diff --git a/Makefile b/Makefile index 87af54d..1b6ec61 100644 --- a/Makefile +++ b/Makefile @@ -42,9 +42,8 @@ test: ## run tests quickly with the default Python python -m pytest --cov=endata --cov-report xml .PHONY: lint -lint: ## check style with flake8 and isort - flake8 endata tests - isort -c --recursive endata tests +lint: ## check style with pre-commit hooks + pre-commit run --all-files .PHONY: install-develop install-develop: clean-build clean-pyc ## install the package in editable mode and dependencies for development @@ -55,10 +54,8 @@ test-all: ## run tests on every Python version with tox tox -r -p auto .PHONY: fix-lint -fix-lint: ## fix lint issues using autoflake, autopep8, and isort - find endata tests -name '*.py' | xargs autoflake --in-place --remove-all-unused-imports --remove-unused-variables - autopep8 --in-place --recursive --aggressive endata tests - isort --apply --atomic --recursive endata tests +fix-lint: ## fix lint issues using pre-commit hooks + pre-commit run --all-files .PHONY: coverage coverage: ## check code coverage quickly with the default Python