This repository describes Python development standards at Shopify, and provides some utilities to assist other Python repositories adhere to these standards.
Shopify follows the Google Python Style Guide with the following exceptions:
Projects that are producing libraries to be used in other projects should choose their release version numbers using Semantic Versioning 2.0.0, i.e.
Given a version number MAJOR.MINOR.PATCH, increment the:
MAJOR version when you make incompatible API changes, MINOR version when you add functionality in a backwards-compatible manner, and PATCH version when you make backwards-compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
All committed code requires quality tests that provide ample code coverage. Functionality that is not covered by tests should be assumed to be broken (and probably will be).
Committing to master
requires a code review, submitted in the form of a GitHub Pull Request. To be merged, a PR must
have an explicit approval from a core team member and no outstanding questions.
To help you apply these principles this repository contains a pylint plugin and some example files to bootstrap a Python project. When beginning a Python project:
pylintrc
file of this form and disable messages in Python source files if needed as agreed upon by team members
fixme
and missing-docstring
messages via pylintrc
is acceptable but these should be removed before a 1.0.0 release of a library or a production deployment of an applicationshopify_python
checker (which this pylintrc
is configured to run) by making a requirements.txt
entry of git+https://github.com/Shopify/shopify_python.git@v0.1.2
(replacing v0.1.2
with the latest version number) and installing it via pip (e.g. pip install -r requirements.txt
)py.test
to run your unit testspytest-randomly
plugin to randomize test order to eliminate test-order dependenciespylint
to lint your code using pylint's default checkers and the shopify_python
checker defined in this projectmypy
to check type annotationsMakefile
similar to the one used by this project to run tests/linters in a similar way on both CI and for local development (or use an internal alternative)Please refer to our Contribution Guidelines