6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-04 19:03:39 +00:00

Introduce automatic code formatting/linting

Code formatting makes sure that the python code looks decent, but it
does not check for coding errors.
https://black.readthedocs.io/en/stable/

Code linting runs static error detection on the python code, but does
not bother about formatting: https://pylint.readthedocs.io/en/latest/
This commit is contained in:
Régis Behmo 2019-05-05 11:40:49 +02:00 committed by Régis Behmo
parent 52c80631c6
commit 9dd4c26706
4 changed files with 41 additions and 3 deletions

View File

@ -7,9 +7,20 @@ compile-requirements: ## Compile requirements files
pip-compile -o requirements/dev.txt requirements/dev.in
pip-compile -o requirements/docs.txt requirements/docs.in
test: ## Run unit tests
test: test-lint test-unit test-format ## Run all tests by decreasing order or priority
test-format: ## Run code formatting tests
black --check --diff tutor
test-lint: ## Run code linting tests
pylint --errors-only tutor
test-unit: ## Run unit tests
nosetests --nocapture tests/
format: ## Format code automatically
black ./tutor
###### Deployment
bundle: ## Bundle the tutor package in a single "dist/tutor" executable
@ -37,7 +48,7 @@ ci-info: ## Print info about environment
python3 --version
pip3 --version
ci-test: ## Run unit tests but without nosetests, which is not available on Mac OS in travis-ci
ci-test: test-format test-lint ## Run unit tests but without nosetests, which is not available on Mac OS in travis-ci
python3 -m unittest discover tests
ci-bundle: ## Create bundle and run basic tests

View File

@ -22,7 +22,22 @@ Run tests
make test
Yes, there are very few tests for now, but this is probably going to change.
Yes, there are very few unit tests for now, but this is probably going to change.
Code formatting
---------------
Tutor code formatting is enforced by `black <https://black.readthedocs.io/en/stable/>`_. To check whether your code changes conform to formatting standards, run::
make test-format
And to automatically fix formatting errors, run::
make format
Static error detection is performed by `pylint <https://pylint.readthedocs.io/en/latest/>`_. To detect errors, run::
make test-lint
Bundle ``tutor`` executable
---------------------------

View File

@ -1,4 +1,6 @@
-r base.txt
black
nose
pip-tools
pylint
pyinstaller

View File

@ -6,6 +6,9 @@
#
altgraph==0.16.1 # via macholib, pyinstaller
appdirs==1.4.3
astroid==2.2.5 # via pylint
attrs==19.1.0 # via black
black==19.3b0
cachetools==3.1.0
certifi==2019.3.9
chardet==3.0.4
@ -14,10 +17,13 @@ click==7.0
future==0.17.1 # via pefile
google-auth==1.6.3
idna==2.8
isort==4.3.18 # via pylint
jinja2==2.10.1
kubernetes==9.0.0
lazy-object-proxy==1.3.1 # via astroid
macholib==1.11 # via pyinstaller
markupsafe==1.1.1
mccabe==0.6.1 # via pylint
nose==1.3.7
oauthlib==3.0.1
pefile==2018.8.8 # via pyinstaller
@ -26,12 +32,16 @@ prompt-toolkit==2.0.9
pyasn1-modules==0.2.4
pyasn1==0.4.5
pyinstaller==3.4
pylint==2.3.1
python-dateutil==2.8.0
pyyaml==5.1
requests-oauthlib==1.2.0
requests==2.21.0
rsa==4.0
six==1.12.0
toml==0.10.0 # via black
typed-ast==1.3.5 # via astroid
urllib3==1.24.2
wcwidth==0.1.7
websocket-client==0.56.0
wrapt==1.11.1 # via astroid