[Django] #25384: New Migrations Generated with Improperly Sorted Imports

2 views
Skip to first unread message

Django

unread,
Sep 11, 2015, 11:16:41 AM9/11/15
to django-...@googlegroups.com
#25384: New Migrations Generated with Improperly Sorted Imports
--------------------------------------+--------------------
Reporter: jambonrose | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+--------------------
New migration files are generated with the following line of code (found
in the `django/db/migrations/writer.py` file):

from django.db import models, migrations

Anytime [https://pypi.python.org/pypi/isort isort] is run on a migration
file (for example, for data migrations), it will reorder the import to:

from django.db import models, migrations

It would be great if we were generating properly sorted documents.

--
Ticket URL: <https://code.djangoproject.com/ticket/25384>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 11, 2015, 11:17:18 AM9/11/15
to django-...@googlegroups.com
#25384: New Migrations Generated with Improperly Sorted Imports
-------------------------------------+-------------------------------------
Reporter: jambonrose | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by mlorant):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Old description:

> New migration files are generated with the following line of code (found
> in the `django/db/migrations/writer.py` file):
>
> from django.db import models, migrations
>
> Anytime [https://pypi.python.org/pypi/isort isort] is run on a migration
> file (for example, for data migrations), it will reorder the import to:
>
> from django.db import models, migrations
>
> It would be great if we were generating properly sorted documents.

New description:

New migration files are generated with the following line of code (found
in the `django/db/migrations/writer.py` file):

from django.db import models, migrations

Anytime [https://pypi.python.org/pypi/isort isort] is run on a migration
file (for example, for data migrations), it will reorder the import to:

from django.db import migrations, models

It would be great if we were generating properly sorted documents.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/25384#comment:1>

Django

unread,
Sep 11, 2015, 11:19:33 AM9/11/15
to django-...@googlegroups.com
#25384: New Migrations Generated with Improperly Sorted Imports
-------------------------------------+-------------------------------------
Reporter: jambonrose | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by collinanderson):

Hi, could you try this out on master (1.9)? I think it _may_ have been
fixed already.

--
Ticket URL: <https://code.djangoproject.com/ticket/25384#comment:2>

Django

unread,
Sep 11, 2015, 11:41:46 AM9/11/15
to django-...@googlegroups.com
#25384: New Migrations Generated with Improperly Sorted Imports
-------------------------------------+-------------------------------------
Reporter: jambonrose | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by jambonrose):

Argh. Collin is right. I was looking at this on the wrong branch. Very
sorry.

--
Ticket URL: <https://code.djangoproject.com/ticket/25384#comment:3>

Django

unread,
Sep 11, 2015, 11:42:24 AM9/11/15
to django-...@googlegroups.com
#25384: New Migrations Generated with Improperly Sorted Imports
-------------------------------------+-------------------------------------
Reporter: jambonrose | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jambonrose):

* status: new => closed
* resolution: => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/25384#comment:4>

Django

unread,
Sep 11, 2015, 11:55:36 AM9/11/15
to django-...@googlegroups.com
#25384: New Migrations Generated with Improperly Sorted Imports
-------------------------------------+-------------------------------------
Reporter: jambonrose | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* resolution: invalid => duplicate


Comment:

(done in #24155)

--
Ticket URL: <https://code.djangoproject.com/ticket/25384#comment:5>

Django

unread,
Sep 11, 2015, 10:02:13 PM9/11/15
to django-...@googlegroups.com
#25384: New Migrations Generated with Improperly Sorted Imports
--------------------------------------+------------------------------------

Reporter: jambonrose | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by MarkusH):

* status: closed => new
* resolution: duplicate =>
* stage: Unreviewed => Accepted


Comment:

As briefly discussed on IRC the other day, I add a patch for 1.8 to change
the order of those two imports. It's annoying to change the order
manually.

The issue is indeed fixed on master.

--
Ticket URL: <https://code.djangoproject.com/ticket/25384#comment:6>

Django

unread,
Sep 11, 2015, 10:31:03 PM9/11/15
to django-...@googlegroups.com
#25384: New Migrations Generated with Improperly Sorted Imports
--------------------------------------+------------------------------------

Reporter: jambonrose | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by MarkusH):

* has_patch: 0 => 1


Old description:

> New migration files are generated with the following line of code (found
> in the `django/db/migrations/writer.py` file):
>
> from django.db import models, migrations
>
> Anytime [https://pypi.python.org/pypi/isort isort] is run on a migration
> file (for example, for data migrations), it will reorder the import to:
>

> from django.db import migrations, models


>
> It would be great if we were generating properly sorted documents.

New description:

New migration files are generated with the following line of code (found
in the `django/db/migrations/writer.py` file):
{{{
from django.db import models, migrations
}}}
Anytime [https://pypi.python.org/pypi/isort isort] is run on a migration
file (for example, for data migrations), it will reorder the import to:
{{{

from django.db import migrations, models


}}}
It would be great if we were generating properly sorted documents.

--

Comment:

PR: https://github.com/django/django/pull/5274

--
Ticket URL: <https://code.djangoproject.com/ticket/25384#comment:7>

Django

unread,
Sep 12, 2015, 7:36:20 AM9/12/15
to django-...@googlegroups.com
#25384: New Migrations Generated with Improperly Sorted Imports
--------------------------------------+------------------------------------
Reporter: jambonrose | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Markus Holtermann <info@…>):

* status: new => closed

* resolution: => fixed


Comment:

In [changeset:"3cc5cc79584b66dafac54264d072ac1206426471" 3cc5cc79]:
{{{
#!CommitTicketReference repository=""
revision="3cc5cc79584b66dafac54264d072ac1206426471"
[1.8.x] Fixed #25384 -- Ordered imports in newly created migration files
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25384#comment:8>

Django

unread,
Sep 12, 2015, 7:40:47 AM9/12/15
to django-...@googlegroups.com
#25384: New Migrations Generated with Improperly Sorted Imports
--------------------------------------+------------------------------------
Reporter: jambonrose | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Migrations | Version: 1.8

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Markus Holtermann <info@…>):

In [changeset:"84b0a8d2aad042fb573df5055b6153770d0929ac" 84b0a8d]:
{{{
#!CommitTicketReference repository=""
revision="84b0a8d2aad042fb573df5055b6153770d0929ac"


Fixed #25384 -- Ordered imports in newly created migration files

Partial forwardport of 3cc5cc79584b66dafac54264d072ac1206426471 from
stable/1.8.x as the issue was already fixed in master in
a7bc00e17bebe34cdf23f744937b3c386ee73d81
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25384#comment:9>

Reply all
Reply to author
Forward
0 new messages