How I work with python, roughly. Bootstrap projects to eliminate toil.
- Cede formatting control to black, it does a fine job and let’s me focus on code rather than style
- Pytest on push, don’t let me push code that fails tests
- Enforce strict static type analysis via mypy; duck typing is convenient but tracing obscure issues later sucks
- Use flake8 for pattern feedback but ignore style issues (black)
- Use isort for well ordered imports
- Provide templates for common tasks
- Pre-commit works great, always use it
Cookiecutter is required to use this cookiecutter template (😉). There are many ways to install cookiecutter, choose what works best for you. I use brew (brew install cookiecutter
), but it’s not the only way.
cookiecutter https://github.com/cadeef/cookiecutter-python.git
Cookiecutter’s documentation is a bit lackluster (I might jump in to help one of these days); a couple tips for using personal configuration via .cookiecutterrc
effectively:
Cookiecutter supports default contexts, as they call them, to provide answers for common questions. Unfortunately, it lacks a specification that suggests expected/reusable variables, so I’ve implemented what makes sense to me. My .cookiecutterrc
looks kinda like this (email address obscured, but feel free to email me if you’re logged in and can see it):
default_context:
author_name: Jimbob Briggs
author_email: [email protected]
Deep in the docs with nary a mention are abbreviations, they make it convenient to select a template without thinking about it. cookiecutter python
is a lot easier to type than cookiecutter https://github.com/cadeef/cookiecutter-python.git
. I define it as:
abbreviations:
python: https://github.com/cadeef/cookiecutter-python.git
Matter of fact this is personal repo. It doesn’t aspire to best practices, though I try to stick to them, but instead what works for me. My aim is to show my process and possibly help you with yours.
If you’re using it, cool! We probably have similar methodologies and I’d love to hear about it. Raise an issue and let’s talk about it, you may have a great idea that I’d like to integrate into my workflow too.
Fork, make it yours. ❤️
If you are still unconvinced and wish to contribute pull requests, please adhere to common sense guidelines.