Skip to content
Snippets Groups Projects
Commit 0ccb0b43 authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Use pre-commit to execute flake8

parent 9f38419f
No related branches found
Tags 1.5.1
No related merge requests found
[flake8]
max-line-length = 120
exclude=build,.eggs,.git,src,arkindex/*/migrations/0001_initial.py,.cache
exclude=build,.cache,.eggs,.git,src,arkindex/*/migrations/0001_initial.py
# Flake8 ignores multiple errors by default;
# the only interesting ignore is W503, which goes against PEP8.
# See https://lintlyci.github.io/Flake8Rules/rules/W503.html
ignore=W503
ignore = E203,E501,W503
......@@ -42,11 +42,23 @@ backend-tests:
- codecov
backend-lint:
extends: .backend-setup
image: python:3
stage: test
cache:
paths:
- .cache/pip
- .cache/pre-commit
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PRE_COMMIT_HOME: "$CI_PROJECT_DIR/.cache/pre-commit"
before_script:
- pip install pre-commit
script:
- flake8
- pre-commit run -a
backend-migrations:
extends: .backend-setup
......
repos:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
additional_dependencies:
- 'flake8-copyright==0.2.2'
- 'flake8-debugger==3.1.0'
- repo: meta
hooks:
- id: check-useless-excludes
default_language_version:
python: python3.7
......@@ -124,8 +124,23 @@ Once your code appears to be working on a local server, a few checks have to be
* **Migrations:** Ensure that all migrations have been created by typing `./manage.py makemigrations`.
* **Unit tests:** Run `./manage.py test` to perform unit tests.
Use `./manage.py test module_name` to perform tests on a single module, if you wish to spend less time waiting for all tests to complete.
* **Code linting:** Type `flake8` inside the `backend/arkindex` directory. Our Flake8 settings should allow 120 characters per line instead of PEP8's 80.
### Linting
We use [pre-commit](https://pre-commit.com/) to check the Python source code syntax of this project.
To be efficient, you should run pre-commit before committing (hence the name...).
To do that, run once :
```
pip install pre-commit
pre-commit install
```
The linting workflow will now run on modified files before committing, and may fix issues for you.
If you want to run the full workflow on all the files: `pre-commit run -a`.
## Debugging tools
Run `pip install ipython django-debug-toolbar django_extensions` to install all the available optional dev tools for the backend.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment