bocdaz / template-python-project

A starter project template for new python project.
0 stars 0 forks source link
cookiecutter python template

Python cookiecutter template

CI - nox sessions

Opinionated cookiecutter template for creating a new Python program, or FastAPI application.

Use this template on your own machine with cookiecutter, or create a brand new repository based on this template entirely through the GitHub web interface using either:

Manual installation

You'll need to have cookiecutter, poetry and pre-commit installed.

Run cookiecutter gh:bocdaz/template-python-project and then answer the prompts.

Getting Started

  1. Run poetry shell
  2. Modify the project name and authors in pyproject.toml
  3. Start adding new python files to src
  4. (Optional) If using DevSpace:
    • Run devspace use context to select the proper cluster.
    • Run devspace use namespace my-namespace to select the namespace to use.
    • Start your project in development mode with devspace dev.

Running Dev Tools

  1. Change to the base directory
  2. In cmd/terminal use nox to run ALL linter, security checks, and tests
    • Use nox --list-sessions to list all possible sessions
    • Use nox -rs lint to run the linter
    • Use nox -rs safety to run security checks
    • Use nox -rs tests to run test suites
    • Use nox -rs black to run the formatter

FAQ

How do I run my python file with poetry?

poetry shell
poetry run ___.py

How do I install new libraries to my project?

poetry add ___

I ran into an issue, what should I do?

Feel free to file an issue, including as much relevant info and screenshots if that helps explain things. Then, the community will be able to diagnose your issue and help resolve it.

What about including in this repository?

We're always open to improvements, no matter how small! To suggest a change to this project template, open an issue and the community will be able to discuss whether to include the tool, and if so, how. If you have a suggestion on how to incorporate the tool as well, feel free to create a PR with the change, and reference it in your issue. That would make it even easier for the community to consider the change.

I'm starting a python project, do I have to use this repo as a starting point?

Definitely not! This repo came about from a desire to have a simple way to setup the tools our team uses for python development. But you're absolutely free to configure the tools to work on your project without using this repository as a starting point.

Useful Resources

Included tools

Name Purpose
coverage.py Coverage.py is a tool for measuring code coverage of Python programs.
flake8 Flake8 is a wrapper around various linting tools, and provides a plggable interface.
flake8-bandit Bandit is a tool designed to find common security issues in Python code.
flake8-black This is an MIT licensed flake8 plugin for validating Python code style with the command line code formatting tool black.
flake8-bugbear A plugin for Flake8 finding likely bugs and design problems in your program.
flake8-comprehensions A flake8 plugin that helps you write better list/set/dict comprehensions.
flake8-docstrings A simple module that adds an extension for the fantastic pydocstyle tool to flake8.
isort isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.
nox nox is a command-line tool that automates testing in multiple Python environments, similar to tox.
mkdocs-material MkDocs is a fast, simple and downright gorgeous static site generator that's geared towards building project documentation. Documentation source files are written in Markdown, and configured with a single YAML configuration file.
pep8-naming Check your code against PEP 8 naming conventions. This module provides a plugin for flake8, the Python code checker.
poetry Poetry helps you declare, manage and install dependencies of Python projects, ensuring you have the right stack everywhere.
pre-commit A framework for managing and maintaining multi-language pre-commit hooks.
pytest The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.
pytest-cov This pytest plugin produces test coverage reports.
pytest-mock This pytest plugin provides a mocker fixture which is a thin-wrapper around the patching API provided by the mock package.
rope Rope is a python refactoring library.
safety Safety checks your dependencies for known security vulnerabilities.
xdoctest The xdoctest package is a re-write of Python's builtin doctest module.