Skip to content

Commit

Permalink
Leverage pre-commit for linting (#128)
Browse files Browse the repository at this point in the history
* chore(flake8): correctly define exclusions
* chore: leverage `pre-commit` for linting code
* build(deps): remove obsolete `black` and `flake8`
* build(deps): bump `flake8` to `5.0.4`
  • Loading branch information
mkniewallner authored Sep 24, 2022
1 parent cbfec5e commit 59159dc
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 137 deletions.
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/psf/black
rev: "22.8.0"
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: "5.10.1"
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: "5.0.4"
hooks:
- id: flake8
19 changes: 9 additions & 10 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,29 @@ development. Please note this documentation assumes you already have
poetry install
poetry shell
| 4. Create a branch for local development:
| 4. Install pre-commit to run linters/formatters at commit time:
.. code-block:: bash
git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
poetry run pre-commit install
| 5. Create a branch for local development:
| 5. Don't forget to add test cases for your added functionality to the ``tests`` directory.
.. code-block:: bash
| 6. When you're done making changes, check that your changes pass the formatting tests.
git checkout -b name-of-your-bugfix-or-feature
.. code-block:: bash
Now you can make your changes locally.

make lint
| 6. Don't forget to add test cases for your added functionality to the ``tests`` directory.
| 7. Now, validate that all unit tests are passing:
| 7. Once you're done, validate that all unit tests are passing:
.. code-block:: bash
make test
| 8. Before raising a pull request you should also run tox. This will run the
| 8. Before creating a pull request you should also run tox. This will run the
tests across different versions of Python:
.. code-block:: bash
Expand Down
17 changes: 4 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
install: ## Install the poetry environment
@echo "🚀 Creating virtual environment using pyenv and poetry"
@poetry install
@poetry install
@poetry shell

format: ## Format code using isort and black.
@echo "🚀 Formatting code: Running isort and black"
@isort .
@black .

check: ## Check code formatting using isort, black, flake8 and mypy.
@echo "🚀 Checking code formatting: Running isort"
@isort --check-only --diff .
@echo "🚀 Checking code formatting: Running black"
@black --check .
@echo "🚀 Checking code formatting: Running flake8"
@flake8 .
check: ## Lint code using pre-commit and check obsolete dependencies using deptry.
@echo "🚀 Linting code: Running pre-commit"
@pre-commit run -a
@echo "🚀 Checking for obsolete dependencies: Running deptry"
@deptry .

Expand Down
Loading

0 comments on commit 59159dc

Please sign in to comment.