flake8 fixes
This commit is contained in:
parent
f16abe44a1
commit
e5b7045422
|
@ -178,9 +178,9 @@ class MigrationOptimizer(object):
|
||||||
if operation.name.lower() == other.old_name.lower():
|
if operation.name.lower() == other.old_name.lower():
|
||||||
return [migrations.CreateModel(
|
return [migrations.CreateModel(
|
||||||
other.new_name,
|
other.new_name,
|
||||||
fields = operation.fields,
|
fields=operation.fields,
|
||||||
options = operation.options,
|
options=operation.options,
|
||||||
bases = operation.bases,
|
bases=operation.bases,
|
||||||
)]
|
)]
|
||||||
|
|
||||||
def reduce_model_rename_self(self, operation, other):
|
def reduce_model_rename_self(self, operation, other):
|
||||||
|
@ -199,54 +199,54 @@ class MigrationOptimizer(object):
|
||||||
if operation.name.lower() == other.model_name.lower():
|
if operation.name.lower() == other.model_name.lower():
|
||||||
return [migrations.CreateModel(
|
return [migrations.CreateModel(
|
||||||
operation.name,
|
operation.name,
|
||||||
fields = operation.fields + [(other.name, other.field)],
|
fields=operation.fields + [(other.name, other.field)],
|
||||||
options = operation.options,
|
options=operation.options,
|
||||||
bases = operation.bases,
|
bases=operation.bases,
|
||||||
)]
|
)]
|
||||||
|
|
||||||
def reduce_create_model_alter_field(self, operation, other):
|
def reduce_create_model_alter_field(self, operation, other):
|
||||||
if operation.name.lower() == other.model_name.lower():
|
if operation.name.lower() == other.model_name.lower():
|
||||||
return [migrations.CreateModel(
|
return [migrations.CreateModel(
|
||||||
operation.name,
|
operation.name,
|
||||||
fields = [
|
fields=[
|
||||||
(n, other.field if n == other.name else v)
|
(n, other.field if n == other.name else v)
|
||||||
for n, v in operation.fields
|
for n, v in operation.fields
|
||||||
],
|
],
|
||||||
options = operation.options,
|
options=operation.options,
|
||||||
bases = operation.bases,
|
bases=operation.bases,
|
||||||
)]
|
)]
|
||||||
|
|
||||||
def reduce_create_model_rename_field(self, operation, other):
|
def reduce_create_model_rename_field(self, operation, other):
|
||||||
if operation.name.lower() == other.model_name.lower():
|
if operation.name.lower() == other.model_name.lower():
|
||||||
return [migrations.CreateModel(
|
return [migrations.CreateModel(
|
||||||
operation.name,
|
operation.name,
|
||||||
fields = [
|
fields=[
|
||||||
(other.new_name if n == other.old_name else n, v)
|
(other.new_name if n == other.old_name else n, v)
|
||||||
for n, v in operation.fields
|
for n, v in operation.fields
|
||||||
],
|
],
|
||||||
options = operation.options,
|
options=operation.options,
|
||||||
bases = operation.bases,
|
bases=operation.bases,
|
||||||
)]
|
)]
|
||||||
|
|
||||||
def reduce_create_model_remove_field(self, operation, other):
|
def reduce_create_model_remove_field(self, operation, other):
|
||||||
if operation.name.lower() == other.model_name.lower():
|
if operation.name.lower() == other.model_name.lower():
|
||||||
return [migrations.CreateModel(
|
return [migrations.CreateModel(
|
||||||
operation.name,
|
operation.name,
|
||||||
fields = [
|
fields=[
|
||||||
(n, v)
|
(n, v)
|
||||||
for n, v in operation.fields
|
for n, v in operation.fields
|
||||||
if n.lower() != other.name.lower()
|
if n.lower() != other.name.lower()
|
||||||
],
|
],
|
||||||
options = operation.options,
|
options=operation.options,
|
||||||
bases = operation.bases,
|
bases=operation.bases,
|
||||||
)]
|
)]
|
||||||
|
|
||||||
def reduce_add_field_alter_field(self, operation, other):
|
def reduce_add_field_alter_field(self, operation, other):
|
||||||
if operation.model_name.lower() == other.model_name.lower() and operation.name.lower() == other.name.lower():
|
if operation.model_name.lower() == other.model_name.lower() and operation.name.lower() == other.name.lower():
|
||||||
return [migrations.AddField(
|
return [migrations.AddField(
|
||||||
model_name = operation.model_name,
|
model_name=operation.model_name,
|
||||||
name = operation.name,
|
name=operation.name,
|
||||||
field = other.field,
|
field=other.field,
|
||||||
)]
|
)]
|
||||||
|
|
||||||
def reduce_add_field_delete_field(self, operation, other):
|
def reduce_add_field_delete_field(self, operation, other):
|
||||||
|
@ -260,9 +260,9 @@ class MigrationOptimizer(object):
|
||||||
def reduce_add_field_rename_field(self, operation, other):
|
def reduce_add_field_rename_field(self, operation, other):
|
||||||
if operation.model_name.lower() == other.model_name.lower() and operation.name.lower() == other.old_name.lower():
|
if operation.model_name.lower() == other.model_name.lower() and operation.name.lower() == other.old_name.lower():
|
||||||
return [migrations.AddField(
|
return [migrations.AddField(
|
||||||
model_name = operation.model_name,
|
model_name=operation.model_name,
|
||||||
name = other.new_name,
|
name=other.new_name,
|
||||||
field = operation.field,
|
field=operation.field,
|
||||||
)]
|
)]
|
||||||
|
|
||||||
def reduce_alter_field_rename_field(self, operation, other):
|
def reduce_alter_field_rename_field(self, operation, other):
|
||||||
|
@ -270,9 +270,9 @@ class MigrationOptimizer(object):
|
||||||
return [
|
return [
|
||||||
other,
|
other,
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name = operation.model_name,
|
model_name=operation.model_name,
|
||||||
name = other.new_name,
|
name=other.new_name,
|
||||||
field = operation.field,
|
field=operation.field,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ accept_language_re = re.compile(r'''
|
||||||
language_code_prefix_re = re.compile(r'^/([\w-]+)(/|$)')
|
language_code_prefix_re = re.compile(r'^/([\w-]+)(/|$)')
|
||||||
|
|
||||||
# some browsers use deprecated locales. refs #18419
|
# some browsers use deprecated locales. refs #18419
|
||||||
_BROWSERS_DEPRECATED_LOCALES = {
|
_BROWSERS_DEPRECATED_LOCALES = {
|
||||||
'zh-cn': 'zh-hans',
|
'zh-cn': 'zh-hans',
|
||||||
'zh-tw': 'zh-hant',
|
'zh-tw': 'zh-hant',
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# encoding: utf8
|
# encoding: utf8
|
||||||
import operator
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.db.migrations.optimizer import MigrationOptimizer
|
from django.db.migrations.optimizer import MigrationOptimizer
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
@ -65,7 +65,7 @@ class OptimizerTests(TestCase):
|
||||||
self.assertOptimizesTo(
|
self.assertOptimizesTo(
|
||||||
[migrations.DeleteModel("Foo")],
|
[migrations.DeleteModel("Foo")],
|
||||||
[migrations.DeleteModel("Foo")],
|
[migrations.DeleteModel("Foo")],
|
||||||
exact = 1,
|
exact=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_delete_model(self):
|
def test_create_delete_model(self):
|
||||||
|
|
Loading…
Reference in New Issue