Skip to content

Raniz85/python-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Project Template

A nice starting point for a modern python project.

Licensing

This template is licensed under the MIT-0 license, meaning you're basically free to do whatever you want with it.

Requirements

Python

You need to have Python 3 installed (obviously), the exact version is configurable in pyproject.toml but defaults to 3.9+

Poetry

You also need to have Poetry installed, check the readme for instructions. Note though that some Linux distributions have a Poetry package available in which case you might want to install that instead.

  • Arch Linux (and derivatives): python-poetry
  • OpenSuse Tumbleweed: python310-poetry, python39-poetry, python38-poetry
  • Fedora: python3-poetry
  • Debian (Sid): python3-poetry

Technologies

Poetry

Poetry is a packaging and dependency manager for Python.

Flake8

Flake8 is a linting tool for Python with a bunch of handy plugins.

Bandit

Bandit Is a code analysis tool for Python for catching security errors.

BugBear

BugBear Is a code analysis tool for finding bugs and design problems.

DocStrings

DocStrings Is a Flake 8 plugin to assert that docstrings are correct and prevalent throughout the codebase.

Black

Black is an uncompromising code formatter for Python. It's designed to format code in a fashion that reduces merge conflicts.

isort

isort "isort your imports, so you don't have to."

Pytest

pytest Is the most popular testing framework for Python that isn't unittest. It integrates well with unittest and adds on a lot of powerful features for testing.

Make

Make is used for scripting the various tooling to make them easy to execute. The Makefile contains targets for each tooling as well as an init target for initialising the project and a ci target suitable for running in a CI pipeline.

Init

make init installs all projects using poetry

Format

make format runs Black and isort on src/ and tests/ to reformat all files and order imports.

Lint

make lint runs flake8 on src/ and tests/ and reports any linting errors, fails if there are any linting errors and succeeds otherwise.

Stylecheck

make stylecheck runs Black in check mode, reporting any changes that would be made instead of making them. Fails if any change would be made and succeeds if no changes would be made

Typecheck

make typecheck runs mypy on src/ and reports any type errors, fails if there is any type errors and succeeds otherwise.

Test

make test runs all tests in tests/ using PyTest, fails if there is any test failures and suceeds otherwise.

CI

make ci is a meta target that depends on stylecheck, lint, typecheck and test and fails if any of those targets fails.

CI

The templates comes pre-baked with CI support for both GitLab and GitHub. It contains one job that runs on pull requests and that runs the ci Make target.

About

A starter template for setting up a modern Python project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published