tools for improving your code
conda env create --file testing.yml
if you want to overwrite an existing environment with the name "testing"
conda env create --force --file testing.yml
NOTE: Don't forget to activate it ;-)
conda activate testing
You can run all these commands also recursively that means it will run for all files in all subfolder from your current working directory with replacing <filename>.py
with .
.
isort
is a library to sort imports alphabetically and automatically separate them into sections by type. You can run it for one file:
isort <filename>.py
black
is the uncompromising Python code formatter. It deletes unnecessary whitespaces and formats your lists, dictionaries, and similar datatypes. You can run this for one file with:
black <filename>.py
NOTE: be aware that sometimes the result can look less readable
flake8
is a tool for style guide enforcement. It outputs you the lines in the script that have an unclean style and how to clean them up. You can run this for one file with:
flake8 <filename>.py
mypy
is a tool for type checking (similar to flake8 for style). It outputs missing or wrong type hints. You can run this for one file with:
mypy <filename>.py
refurb
is a tool for modernizing Python codebases. It outputs hints for optimizing your code. You can run this for one file with:
refurb <filename>.py
pytest
is tool for writing small and readable tests for your code. You can run this with:
pytest
create in your repository the folder structure .github/workflows/
and add there code_quality.yml
to check your code quality after every push.