Code Monkey home page Code Monkey logo

wolt-python-package-cookiecutter's Introduction

Wolt Python Package Cookiecutter

A cookiecutter (project template) for rapidly developing new open source Python packages. Best practices with all the modern bells and whistles included.

Demo

Example projects which use Wolt Python Package Cookiecutter

Features

Automatic updates to the projects generated from this cookiecutter

  • Powered by cruft
  • Keep your project up-to-date with best practices

Continuous integration

  • Powered by Github Actions
  • Testing against multiple different versions

Documentation

Automated releases

  • Publishing to PyPI when a release is made in GitHub

Changelog management

  • Gently enforced: Keep a Changelog
  • GitHub releases get their description automatically populated based on the changelog content
  • The Unreleased section is automatically updated when a release is done
  • Changelog is embedded in the documentation

Bells and whistles

  • Poetry for managing dependencies and packaging
  • pre-commit for running all the goodies listed below
  • mypy for static type checking
  • ruff for automatic formatting, linting and automatically fixing some linting errors

Automation

  • Updates to the best practices (via GHA workflow which runs cruft update and creates a PR)
  • Dependency updates (via GHA workflow which creates a PR)

Usage

Make sure you have cruft installed. Alternatively, you can use cookiecutter if you are not interested in getting updates to the project "boilerplate" in the future.

Create a new project:

cruft create https://github.com/woltapp/wolt-python-package-cookiecutter

The CLI interface will ask some basic questions, such the name of the project, and then generate all the goodies automatically.

After that you can make it a proper git repo:

cd <your-project-slug>
git init
git add .
git commit -m "Initial project structure from Wolt Python Package cookiecutter"

We update this cookiecutter template regularly to keep it up-to-date with the best practices of the Python world. You can get the updates into your project with:

cruft update

Configure secrets

PYPI_TOKEN

Required for publishing the package to PyPI. You can generate a token by logging into PyPI and navigating to Add API token in your account settings.

AUTO_UPDATE_GITHUB_TOKEN

This cookiecutter template comes with an auto update feature if the project was created using cruft. A GitHub action automatically checks for updates and creates a pull request.

Generate personal access token and use it as the value for AUTO_UPDATE_GITHUB_TOKEN secret. When creating the access token, the following permissions have to be granted

  • repo
  • workflow

After the first release

The first release will create gh-pages branch which will contain the static files for the documentation. Enable GitHub Pages in the Pages section of the repository settings.

wolt-python-package-cookiecutter's People

Contributors

davidparsson avatar escaped avatar jerry-git avatar joaopalmeiro avatar rtaycher avatar srv6d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wolt-python-package-cookiecutter's Issues

request: support gitlab

My company uses gitlab, any chance you can add support for gitlab? pretty please ๐Ÿ™

Flake8 Ignore Syntax Change in setup.cfg

I came across an issue where the default flake8 ignore codes were not ignored. Referring to the docs, ignore overrides the default list which includes: E121,E123,E126,E226,E24,E704,W503,W504. The alternative is to use the extend-ignore, which doesn't overwrite the default ignore list. In either event, it would be helpful to include a note regarding this in the setup.cfg file or change the configuration to 'extend-ignore'.
as per https://flake8.pycqa.org/en/latest/user/configuration.html

question: why not mypy strict?

Hi,

In your article and this project, a few MyPy configurations are setuped.

I wonder why MyPy strict is not replacing some of them?

For instance, MyPy version 0.942 defines --strict as:

  --strict                  Strict mode; enables the following flags: --warn-unused-configs,
                            --disallow-any-generics, --disallow-subclassing-any, --disallow-
                            untyped-calls, --disallow-untyped-defs, --disallow-incomplete-
                            defs, --check-untyped-defs, --disallow-untyped-decorators, --no-
                            implicit-optional, --warn-redundant-casts, --warn-unused-ignores,
                            --warn-return-any, --no-implicit-reexport, --strict-equality

[Improvement] Initial build fails due to test

If I clone the cookie cutter and upload it as is, the build failed. This has to do with the testing directory. I added atest_noop.py unit test and then it all worked. Maybe include this in the initial template for a clean build?

def test_noop() -> None:
    assert True

Update pre-commit and other good checks to add

Pre-commit is up to 4.3.0 from 4.0.1 (can usually run pre-commit autoupdate)

Also just a few suggestions for good things to have for most repos:

    # Identify invalid files
    - id: check-ast                        
    - id: check-yaml                       
    - id: check-json                       
    - id: check-toml                       

    # git checks
    - id: check-merge-conflict             
    - id: check-added-large-files          
    - id: detect-private-key               
    - id: check-case-conflict              

    # Python checks
    - id: check-docstring-first            
    - id: debug-statements                 
    - id: requirements-txt-fixer           
    - id: fix-encoding-pragma              
    - id: fix-byte-order-marker            

    # General quality checks
    - id: mixed-line-ending                
    - id: trailing-whitespace              
      args: [--markdown-linebreak-ext=md]  
    - id: check-executables-have-shebangs  
    - id: end-of-file-fixer  

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.