#34420: Migration import ordering violates coding style and isort defaults
-------------------------------------+-------------------------------------
Reporter: Andy | Owner: nobody
Chosak |
Type: | Status: new
Cleanup/optimization |
Component: | Version: 4.1
Migrations |
Severity: Normal | Keywords: migrations
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
New migration files are generated with imports sorted by module,
independent of import style. For example:
{{{#!python
import datetime
from django.db import migrations, models
import time
}}}
The [[https://docs.djangoproject.com/en/dev/internals/contributing
/writing-code/coding-style/#imports|Django coding style]] specifies:
Place all {{{import}}} module statements before {{{from module import
objects}}} in each section.
This guidance is the same as what isort does by default,
[[https://pycqa.github.io/isort/docs/configuration/custom_sections_and_ordering.html
#controlling-how-isort-sections-from-imports|as documented here]]. Newly
generated migrations can fail isort for this reason.
This would mean migration files should instead be generated like this:
{{{#!python
import datetime
import time
from django.db import migrations, models
}}}
For reference, previous issues related to migration import sorting:
#24155, #25384.
--
Ticket URL: <https://code.djangoproject.com/ticket/34420>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070186f082d300-58f7c7f8-e8ca-44b6-97d9-af2ad5684787-000000%40eu-central-1.amazonses.com.