From 76f214df30c44c5afd45418ba801fefd1fea6642 Mon Sep 17 00:00:00 2001 From: Marcel Marques Date: Fri, 9 Apr 2021 23:07:42 -0300 Subject: [PATCH 1/3] Atualizando configuracoes de pre-commit --- .pre-commit-config.yaml | 53 +++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 645f09ed..0d1d3ebc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,25 +1,42 @@ -exclude: 'docs|node_modules|.git|.tox' -default_stages: [commit] -fail_fast: true +exclude: '.git|.tox|migrations|brasilio/wsgi.py|docker' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: master + rev: v3.4.0 hooks: - id: trailing-whitespace files: (^|/).+\.(py|html|sh|css|js)$ -- repo: local - hooks: - - id: flake8 - name: flake8 - entry: flake8 - language: python - types: [python] - args: ['--config=setup.cfg'] - - id: black - name: black - entry: black . - language: python - types: [python] - args: ['--check', '-l', '120', '--exclude', 'docker'] +- repo: local + hooks: + - id: autoflake + name: autoflake + entry: autoflake + language: python + types: + - python + args: [--in-place, --recursive, --remove-unused-variables, --remove-all-unused-imports] + + - id: isort + name: "format imports with isort" + entry: isort + language: python + types: + - python + args: [--line-length=120] + + - id: black + name: "format code with black" + entry: black + language: python + types: + - python + args: [--line-length=120] + + - id: flake8 + name: "lint code with flake8" + entry: flake8 + language: python + types: + - python + args: [--config=setup.cfg] \ No newline at end of file From 5bbf95414fa63c6c236069a32757ea758ac785ee Mon Sep 17 00:00:00 2001 From: Marcel Marques Date: Fri, 9 Apr 2021 23:09:17 -0300 Subject: [PATCH 2/3] Adiciona pre-commit e atualiza isort tornando-o compativel --- requirements-development.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements-development.txt b/requirements-development.txt index 9ffb1d63..0830b4fd 100644 --- a/requirements-development.txt +++ b/requirements-development.txt @@ -3,8 +3,9 @@ autoflake==1.3.1 black==19.10b0 flake8==3.7.9 -isort==4.3.21 +isort==5.8.0 model-bakery==1.1.0 pytest-django==3.2.1 pytest-env==0.6.2 pytest==4.4.1 +pre-commit==2.12.0 \ No newline at end of file From 70f0cc5f9faf57cb6ea80b127f89655be4029ecc Mon Sep 17 00:00:00 2001 From: Marcel Marques Date: Fri, 16 Apr 2021 13:50:55 -0300 Subject: [PATCH 3/3] Adicionando processo de instalacao pre-commit hooks na doc --- docs/dev-process.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/dev-process.md b/docs/dev-process.md index b17a9368..1b27aec9 100644 --- a/docs/dev-process.md +++ b/docs/dev-process.md @@ -24,6 +24,13 @@ make run Nosso arquivo [Makefile](https://github.com/turicas/brasil.io/blob/develop/Makefile) possui outras entradas que podem te ser úteis durante o processo de desenvolvimento. +### Utilizar Pre-commit hooks +Com o pre-commit hooks toda vez que um novo commit for feito durante o desenvolvimento será verificado se o código commitado está no formato ideal. Caso não esteja, será automaticamente corrigido gerando uma modificação com as correções. Para ativá-lo o comando é: + +``` +pre-commit install +``` + ### Padrões de arquivos de apps O projeto segue alguns padrões de organização dos arquivos das apps Django. Mais especificamente em relação aos arquivos estáticos, templates e de testes.