Giter Club home page Giter Club logo

python-new-project's Introduction

Cookiecutter template for starting new modern Python projects

This template allows you to easily setup new Python projects with the most important libraries and configuration files for managing dependencies and virtualenv, code formatting, debugging, testing, static code analysis and creating command-line interfaces.

You can use it as-is or fork and modify according to your preferences.

What is included in the template

The template will:

  • create pyproject.toml configuration file for managing project dependencies and virtualenv using Poetry
  • install typer and rich packages for creating command-line interfaces which are useful in many types of projects
  • install pysnooper and stackprinter for better debugging
  • install Pytest and create pytest.ini configuration file to point Pytest to tests/ folder
  • install Pytest-sugar plugin for nicer Pytest output
  • install Black for code formatting
  • install Flake8 for finding bugs
  • install MyPy for static type checking and create mypy.ini configuration file
  • install pre-commit to run Black, Flake8 checks before every commit
  • install bandit for security-related checks
  • create README.md README file
  • create .gitignore file
  • initialize new Git repository

How to use the template

This is a cookiecutter template.

To use it, make sure you have at least Python 3.7 and git installed.

Then install cookiecutter and poetry via pip:

pip install poetry --user
pip install cookiecutter --user

Then you can create a new Python project by running:

cookiecutter https://github.com/stribny/python-new-project

This will take you to a project setup asking for:

  • project_name, the Python package name and name of the project folder
  • project_description, the Python package description
  • human_name, the name that will be used in generated README file
  • author, the author of the package
  • python_version, the Python version that should be set for the project

The generated structure looks like this:

project_name/ 
└────   project_name/ 
   └────   __init__.py  
├────   .flake8  
├────   .git/ 
├────   .gitignore  
├────   mypy.ini  
├────   poetry.lock  
├────   .pre-commit-config.yaml  
├────   pyproject.toml  
├────   pytest.ini  
├────   README.md  
└────   tests/ 
   ├────   __init__.py  
   └────   test_project.py

Configuring MyPy

By default, MyPy will be installed in the project, but not added as a pre-commit hook. This is because pre-commit would run MyPy in a different virtualenv which will make MyPy unable to pick up your installed dependencies. If you want to add MyPy to your pre-commit hook, read the instructions here.

Additional resources

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.