This repository holds a minimal but complete python3
package
with the following quality services already included:
setuptools
flow for packaging;unittest
test suite sub-package suited for Test Driven Development;coverage
for test suite;bandit
andsafety
for security tests;pylint
andflake8
for syntax checks;mypy
for type hints checks and errors;black
andisort
for code formatting;jupyter
notebooks rendering (with Sphinx integration);Sphinx
documentation builder;anybadge
for any session badges;nox
for session coordination;- GitLab CI Pipeline and GitHub Workflow (future).
To start a new project from this package few steps are required:
- Fork this repository to your hub account and rename it;
- Clone the forked repository to your workspace;
- Rename the project by renaming the package directory;
- Start to implement your project as usual.
Running Code Quality tool suite for this package requires
Code Quality packages are installed (defined in ./docs/requirements.txt
):
python -m pip install -r ./docs/requirements_ci.txt
Code Quality environment is also available in a dedicated Docker image.
Then, to check package capabilities (aka nox
sessions), issue:
nox --list
- clean -> Package Code Cleaner
- package -> Package Builds (badge)
- install -> Package Installer
- uninstall -> Package Uninstaller
* tests -> Package Test Suite Report (badge)
* coverage -> Package Test Suite Coverage Report (badge)
* security -> Package Security Report (badges)
* linter -> Package Linter Report (badge)
* syntax -> Package Syntax Report (badge)
* types -> Package Type Hints Report (badge)
* styles -> Package Code Styles Report (badge)
- notebooks -> Package Notebooks (badge)
- docs -> Package Documentation (badge)
Create a virtual environment if required and activate it:
python3 -m virtualenv venv
source venv/bin/activate
This package follows the usual setuptools
flow, installation is as simple as:
python3 setup.py install
This will install dependencies as well (as defined in requirements.txt
).
To build a wheel and install from it, then issue:
nox --session package install
This package uses unittest
to create its test suite,
to run the complete package test suite, issue:
nox --session tests
This package uses coverage
to assess code coverage.
To run the test suite coverage, issue:
nox --session coverage
This package uses bandit
for security checks.
To check package python security know vulnerabilities, issue:
nox --session security safety
This package uses pylint
and flake8
for syntax checks.
To check package python syntax, issue:
nox --session linter syntax
This package uses mypy
to check types hints.
To check type hints and common errors, issue:
nox --session types
This package uses black
and isort
to check or coerce python code styles.
To check if your code is black, issue:
nox --session styles
To actually style the package code inplace, issue:
nox --session clean
This package uses jupyter
notebooks for tests and documentation purposes.
To refresh all notebooks, issue:
nox --session notebooks
Note: it will rely on previously defined virtual environment venv
.
This package uses Sphinx to build documentation. To generate the package documentation, issue:
nox --session docs
All badges are automatically generated for each nox
session using anybadge
and related report
contents (see noxfile.py
for details).