Starting up new projects, especially command-line applications, can often be tedious. It's hard to remember all of the tools that are used to speed up development and how they're properly configured. This repository allows that step to be recycled by providing a starter CLI with everything needed out of the box, including testing automation through Github Actions.
This repository is offered under an MIT license and is free to be used however one might prefer
You'll most likely want to name things differently. The most glaring example is how the term 'project' is used here as the name of the application. I have tried to minimize the number of places where it is used to make it easier to adapt this repository to different needs. You should edit the following, ensuring that all have the same new name:
- The
project
directory, naming it as makes sense for your project - Inside the
tests/cli_test.py
file, edit the following line:import project.main as main
- Inside the
setup.cfg
file, edit the following lines:addopts = --cov=project --cov-report term-missing
files = project/**/*.py
- Inside the
setup.py
file:name='project'
'console_scripts': ['project = project.main:main']
To install, run the convenience script included with this repository or execute the following code below in your terminal. It is highly recommended that a virtual environment is used for this (and all) Python applications.
pip install -r requirements.txt -r test-requirements.txt -e .;
pre-commit install;
pre-commit run --all-files;
mypy;
pytest;
pre-commit
is a tool used to run a series of checks before git commit
is finished executing. This may seem cumbersome or annoying, but it'll often catch little mistakes that degrade code quality over time. Quite a few of the checks that it runs will also fix the problems that they are checking for.
flake8
is a linter. You can read some more about linters here.
Also check out their repository and their documentation
mypy
is a static type analyzer. Python is a dynamically typed language, and mypy
doesn't seek to change that. However, they do hope to add some of the benefits of static typing, such as legibility. It's a fairly popular tool, and you can read some of its benefits here. If you're new to python type hints (they were introduced in Python 3.5), check out the docs
pytest
is a popular python testing framework. It has good outputs and plenty of plugins, including a coverage report to see how much of your code is covered by tests.
The following links might be helpful: