Adoption of a new Import Ordering Standard

For years we have supported the same import ordering rules in our CONTRIBUTING.md files as part of the Pinax coding style. One feature of this was separate sections for both django and django.contrib. Time has come for that to change.

In the early days, there was a sense that there was a distinction being made between was it was in Django’s core and what was in django.contrib. We were honoring that distinction by having import sections separate.

Photo by davide ragusa

This past month or so we’ve been getting a lot of contributions on Pinax Stripe and there were some style preferences of grouping django.contrib with the rest of django that came out of that. This prompted some discussion in #design-decisions channel in the Pinax Slack Workspace and we decided to make the change.

This decision is in part as it seems the view on django.contrib has shifted since the early days. It is also in part of just adjusting on style preference a bit to reduce friction for our contributors.

One nice addition since those early days is now we have a fantastic tool to help us comply and keep our code nice and tidy with isort.

The following config for isort will be added to the tox.ini for Pinax projects to both better communicate this new standard and provide an easy way for people to use the utility on modules to ensure things are kept sorted properly.

[isort]
multi_line_output=3
known_django=django
sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER

We can now actually lint the import ordering as part of our continuous integration processes. Automating more FTW!