Use this template repository for fast Python development or test automation framework setup
- Poetry for dependency management
- Pre-commit for code consistency and quality
- Editorconfig for compatible code editor configuration
This repository includes .vscode workspace configuration for Python language, linter, formatter and editor customization
This repository includes flake8, black and isort tools to maintain code consistency and quality. These tools together with VSCode configuration helps code quality while developing but they will run on commit and on pull request on GitHub
The configuration file for these tools are:
.flake8for flake8 linterpyproject.tomlfor black and isort formatter[tool.black]for black configuration[tool.isort]for isort configuration, uses black as profile
This repository includes pre-commit that runs on commit and have the following repo hooks:
pre-commit-hookssome built-in hookspoetrypoetry-checkto check if poetry configuration is not brokenpoetry-lockto make surepoetry.lockfile is up-to-datepoetry-exportto export installed packages todev-requirements.txtfor the ones installed withpoetry install --group devand torequirements.txtto include main packages, excluding thedev
localfor local hooks using the same configuration used in theLinter and Formattersectionblackto check code formatting and show diff on FAIL and again to auto-format the code based on thepyproject.tomlconfigurationisortto sort imports, usingblackas profileflake8to code lint and style checks using.flake8file
This repository includes a GitHub Action workflow on .github/workflows/ci.yaml that runs the pre-commit on all files in the Pull Request
Follow these steps to create a new repository using this template:
From this repository URL, select Use this template -> Create new repository, type a name for your repository, choose the repository visibility and make sure to check Include all branches so you have access to other Python versions setup
After cloning the new repository, change to the corresponding branch of the Python version you want to use on your project. Rename or remove src/template_project directory and update section [tool.poetry] from pyproject.toml file and run the following commands to install project dependencies and pre-commit:
Make sure to have the corresponding Python version installed and to be in use in the current shell. As recommendation, use Pyenv to manage multiple Python versions
python-template-project ❯ poetry shell
python-template-project (template-project-py3.11) ❯ poetry update
python-template-project (template-project-py3.11) ❯ pre-commit installIf you don't want to use poetry, you can use the [dev-]requirements.txt files as they are synched with the poetry dependencies but then you have to control them yourself
NOTE:
- You can remove any other branch you don't need
- You can set the selected branch to be the
default, remove themainbranch and then rename the selected one tomainor anything you desire
Reference:
From https://devguide.python.org/versions/
- Python 3.7
- Python 3.8
- Python 3.9
- Python 3.10
- Python 3.11
As some of the tools available doesn't support anymore or are not available for Python 3.6, the branch setup will not be created in this template. If you really need it, feel free to use this template and configure it to Python 3.6 as you wish, if possible