We are using some tools to keep a default coding style in the project.
-
git pre-commit hooks to lint and perform some standardization on every commit.
-
codacy, a platform integrated to github that executes static code quality analysis and track quality evolution.
We following the Numpy docstring style with PEP484.
Flake8 is a python linter that helps to keep the code up to PEP standards.
Mypy is a static type checker for python
To lint the code, run: make lint
Next we'll explain the steps to use the pre-commit hooks.
-
Download and install the python package
pre-commitconda install -c conda-forge pre-commitorpip install pre-commit- In the repository folder, run
pre-commit install
-
With
pre-commit, the next time you make a commit, it will analise your code to match the hooks defined in the.pre-commit-config.yamlfile.
Fix double quoted strings................................................Passed
Trim Trailing Whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook
Fixing pymove/core/dataframe.py
Fix End of Files.........................................................Passed
Mixed line ending........................................................Passed
Check for added large files..............................................Passed
Don't commit to branch...................................................Passed
seed isort known_third_party.............................................Failed
isort....................................................................Failed
- hook id: isort
- files were modified by this hook
Fixing pymove/core/dataframe.py
Fixing pymove/utils/trajectories.py
flake8...................................................................Failed
- hook id: flake8
- exit code: 1
pymove/utils/constants.py:64:5: F601 dictionary key 11 repeated with different values
pymove/utils/constants.py:65:5: F601 dictionary key 12 repeated with different values
pymove/utils/constants.py:74:5: F601 dictionary key 11 repeated with different values
pymove/utils/constants.py:75:5: F601 dictionary key 12 repeated with different values
pymove/core/dataframe.py:970:29: E711 comparison to None should be 'if cond is None:'
-
Fix double quoted strings: Checks and fixes every string declaration is made using single quotes.
-
Trim Trailing Whitespace: Checks and fixes so there are no trailing whitespaces.
-
Fix End of Files: Checks and fixes so that all files end's with a blank line.
-
Mixed line endings: Checks and fixes line breaks to use the unix
LF. -
Check for added large files: Doesn't allow files bigger than
15Mbto be commited. -
Don't commit to branch: Doesn't allow direct commits to
masterbranch. -
isort: Sorts the imports.
-
flake8: Ensures that the code follows
pylintandpyflakesguidelines. It will point the errors in the code. -
mypy: Performs type checking. It will point the errors in the code.
Codacy statically analyzes Pull Requests made into the master and developer branches.
Codacy uses the tools Bandit, Prospector, PyLint and Remark Lint;
The error encountered will be pointed by Codacy as PR Comments.