ShaneNolan / python-project-template

Automated creation of Python projects with enforced coding standards.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python Project Template

Python Version mypy pytest nitpick safety pre-commit wemake-python-styleguide

Automated creation of Python projects with enforced coding standards.

Prerequisites

  • Python 3.6 or above installed (preferably using pyenv).
  • Poetry installed.
  • EditorConfig installed.

Usage

Rename MY_PROJECT_NAME to the name of your project.

# Specify the Python version you want to use with pyenv.
# Ignore this command if you don't use pyenv.
pyenv shell 3.9.0

---------------------------------------------
# Mac OS: Specify the name of the project.
export PROJECT_NAME="MY_PROJECT_NAME"

# Windows: Specifcy the name of the project.
set PROJECT_NAME="MY_PROJECT_NAME"
---------------------------------------------

python -m pip install cookiecutter &&
python -m cookiecutter --no-input gh:ShaneNolan/python-project-template \
project_name=$PROJECT_NAME &&
(cd $PROJECT_NAME && git init &&
poetry init --no-interaction --name $PROJECT_NAME &&
poetry add mypy pytest pytest-cov flake8-pytest-style safety wemake-python-styleguide pre-commit nitpick --dev &&
poetry run nitpick fix &&
poetry run pre-commit install) && python -m uninstall cookiecutter

Validate Setup

To validate your setup you can execute the following commands from inside the project directory (where pyproject.toml exists).

poetry run nitpick check
> No violations found. ✨ 🍰 ✨ # Confirms a successful setup.

poetry run pre-commit run --all-files
> Check for added large files..........................(no files to check)Skipped
> Trim Trailing Whitespace.............................(no files to check)Skipped
> Fix End of Files.....................................(no files to check)Skipped
> Check for merge conflicts............................(no files to check)Skipped
> Check for case conflicts.............................(no files to check)Skipped
> Check JSON...........................................(no files to check)Skipped
> Check Toml...........................................(no files to check)Skipped
> Check Yaml...........................................(no files to check)Skipped
> Pretty format JSON...................................(no files to check)Skipped
> Check python ast.....................................(no files to check)Skipped
> Debug Statements (Python)............................(no files to check)Skipped
> Check docstring is first.............................(no files to check)Skipped
> local flake8.........................................(no files to check)Skipped
> local mypy...........................................(no files to check)Skipped
> local pytest coverage................................(no files to check)Skipped
> local safety.........................................(no files to check)Skipped
# Having no files to check is normal for a new project πŸ˜‰ .

tree -a
>
β”œβ”€β”€ .editorconfig
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .nitpick.toml
β”œβ”€β”€ .pre-commit-config.yaml
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ README.md
β”œβ”€β”€ PROJECT_NAME
β”‚   └── __init__.py
β”œβ”€β”€ poetry.lock
β”œβ”€β”€ pyproject.toml
β”œβ”€β”€ setup.cfg
└── tests
    └── __init__.py

2 directories, 11 files
# Your project structure should look like this.

Connect project to remote repository.

For a new project you will likely need to conect it with a remote repository.

git remote add origin REPOSITORY_URL

Congratulations, you've successfully setup and configured your Python environment πŸŽ‰ .

About

Automated creation of Python projects with enforced coding standards.


Languages

Language:Python 100.0%