Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
Setup new code quality tools and drop pylint
Browse files Browse the repository at this point in the history
Welcome black, isort and flake8.
Drop pylint which is slow as hell.
  • Loading branch information
dejafait committed Mar 13, 2020
1 parent 7311af3 commit 0b284df
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 88 deletions.
75 changes: 0 additions & 75 deletions .pylintrc

This file was deleted.

27 changes: 19 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,25 @@ clean-services: stop-services ## Delete containers and attached volumes
# Code quality
# ------------

# Run pylint on the whole project.
pylint-all:
pylint --rcfile=.pylintrc --reports=no --output-format=colorized $(PACKAGE_DIR) || true

# Run pylint on a specific file, e.g.:
# make pylint FILE=labonneboite/web/app.py
pylint:
pylint --rcfile=.pylintrc --reports=no --output-format=colorized $(FILE) || true
quality:
docker exec -ti itou_django black --check --line-length 119 itou
docker exec -ti itou_django isort --check-only --recursive itou
docker exec -ti itou_django flake8 itou

black:
black --line-length 119 .

isort:
isort --recursive .

flake8:
flake8 .

setup_git_pre_commit_hook:
touch .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
echo "docker exec -t itou_django black --line-length 119 itou" > .git/hooks/pre-commit
echo "docker exec -t itou_django isort --recursive itou" >> .git/hooks/pre-commit


# Local dev
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Table of contents:
- [Elastic Search](#elasticsearch)
- [DB content in the development environment](#db-content-in-the-development-environment)
- [Running scripts](#running-scripts)
- [Running Pylint](#running-pylint)
- [Running Pylint](#running-pylint) FIXME
- [Debugging safely in development, staging or production](#debugging-safely-in-a-development-staging-or-production-environment)
- [Importer](#importer)
- [Single ROME versus multi-ROME search](#single-rome-vs-multi-rome-search)
Expand Down Expand Up @@ -236,6 +236,8 @@ For example `create_index`:

## Running pylint

FIXME

You can run [pylint](https://www.pylint.org) on the whole project:

$ make pylint-all
Expand Down
7 changes: 6 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ huey
Flask-DebugToolbar
ipdb
ipython
pylint
pip-tools

# Code quality.
pylint
flake8
black==19.3b0
isort

# profiling tools used in create_index.py
pycallgraph
pyprof2calltree
Expand Down
15 changes: 12 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@
# pip-compile --output-file requirements.txt requirements.in
#
alembic==0.9.10
appdirs==1.4.3 # via black
appnope==0.1.0 # via ipython
astroid==1.6.5 # via pylint
attrs==19.3.0 # via black
babel==2.6.0 # via flask-babelex
backcall==0.1.0 # via ipython
black==19.3b0
blinker==1.4 # via flask-debugtoolbar, raven
certifi==2017.4.17 # via requests
chardet==3.0.4 # via requests
click==6.7 # via flask, pip-tools
click==6.7 # via black, flask, pip-tools
cssmin==0.2.0
decorator==4.3.0 # via ipython, traitlets, validators
defusedxml==0.5.0 # via python3-openid, social-auth-core
easyprocess==0.2.3 # via pyvirtualdisplay
elasticsearch==1.9.0
entrypoints==0.3 # via flake8
first==2.0.1 # via pip-tools
flake8==3.7.8
flask-admin==1.5.3
flask-assets==0.12
flask-babelex==0.9.3
Expand All @@ -40,7 +46,7 @@ idna==2.5 # via requests
ipdb==0.11
ipython-genutils==0.2.0 # via traitlets
ipython==6.4.0
isort==4.2.15 # via pylint
isort==4.3.21
itsdangerous==0.24 # via flask, flask-debugtoolbar
jedi==0.12.0 # via ipython
jinja2==2.10.1 # via flask, flask-babelex
Expand All @@ -51,7 +57,7 @@ locustio==0.7.5
mailjet-rest==1.3.3
mako==1.0.7 # via alembic
markupsafe==1.1.1
mccabe==0.6.1 # via pylint
mccabe==0.6.1 # via flake8, pylint
msgpack-python==0.5.6 # via locustio
mysqlclient==1.4.2.post1
nose==1.3.7
Expand All @@ -67,7 +73,9 @@ pip-tools==2.0.2
prompt-toolkit==1.0.15 # via ipython
ptyprocess==0.6.0 # via pexpect
pycallgraph==1.0.1
pycodestyle==2.5.0 # via flake8
pycryptodomex==3.6.3 # via pyjwkest
pyflakes==2.1.1 # via flake8
pygments==2.2.0 # via ipython
pyjwkest==1.4.0 # via social-auth-core
pyjwt==1.5.2 # via social-auth-core
Expand Down Expand Up @@ -99,6 +107,7 @@ social-auth-storage-sqlalchemy==1.1.0 # via social-auth-app-flask-sqlalchemy
speaklater==1.3
sqlalchemy-utils==0.32.13
sqlalchemy==1.3.3
toml==0.10.0 # via black
traitlets==4.3.2 # via ipython
unidecode==0.4.21 # via python-slugify
urllib3==1.24.3 # via elasticsearch, requests, selenium
Expand Down
21 changes: 21 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# - https://timothycrosley.github.io/isort/
# - https://github.com/timothycrosley/isort#configuring-isort
# - https://github.com/timothycrosley/isort/wiki/isort-Settings

[isort]
combine_as_imports = True
ensure_newline_before_comments = True
force_grid_wrap = 0
include_trailing_comma = True
known_first_party = labonneboite
lines_after_imports = 2
line_length = 119
multi_line_output = 3
use_parentheses = True

# - https://www.flake8rules.com
# - http://flake8.pycqa.org/en/3.1.1/user/ignoring-errors.html#changing-the-ignore-list

[flake8]
ignore = E203, W503
max-line-length = 119

0 comments on commit 0b284df

Please sign in to comment.