1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Refs #23968 -- Removed unnecessary lists, generators, and tuple calls.

This commit is contained in:
Jon Dufresne
2017-06-01 16:08:59 -07:00
committed by Tim Graham
parent edee5a8de6
commit 2c69824e5a
63 changed files with 145 additions and 150 deletions

View File

@@ -1065,14 +1065,14 @@ class MigrationAutodetector:
old_model_name = self.renamed_models.get((app_label, model_name), model_name)
old_model_state = self.from_state.models[app_label, old_model_name]
new_model_state = self.to_state.models[app_label, model_name]
old_options = dict(
option for option in old_model_state.options.items()
if option[0] in AlterModelOptions.ALTER_OPTION_KEYS
)
new_options = dict(
option for option in new_model_state.options.items()
if option[0] in AlterModelOptions.ALTER_OPTION_KEYS
)
old_options = {
key: value for key, value in old_model_state.options.items()
if key in AlterModelOptions.ALTER_OPTION_KEYS
}
new_options = {
key: value for key, value in new_model_state.options.items()
if key in AlterModelOptions.ALTER_OPTION_KEYS
}
if old_options != new_options:
self.add_operation(
app_label,

View File

@@ -496,7 +496,7 @@ class AlterUniqueTogether(FieldRelatedOptionOperation):
def __init__(self, name, unique_together):
unique_together = normalize_together(unique_together)
self.unique_together = set(tuple(cons) for cons in unique_together)
self.unique_together = {tuple(cons) for cons in unique_together}
super().__init__(name)
def deconstruct(self):
@@ -550,7 +550,7 @@ class AlterIndexTogether(FieldRelatedOptionOperation):
def __init__(self, name, index_together):
index_together = normalize_together(index_together)
self.index_together = set(tuple(cons) for cons in index_together)
self.index_together = {tuple(cons) for cons in index_together}
super().__init__(name)
def deconstruct(self):

View File

@@ -55,7 +55,7 @@ class MigrationRecorder:
def applied_migrations(self):
"""Return a set of (app, name) of applied migrations."""
self.ensure_schema()
return set(tuple(x) for x in self.migration_qs.values_list("app", "name"))
return {tuple(x) for x in self.migration_qs.values_list("app", "name")}
def record_applied(self, app, name):
"""Record that a migration was applied."""

View File

@@ -559,7 +559,7 @@ class ModelState:
# First, make a Meta object
meta_contents = {'app_label': self.app_label, "apps": apps}
meta_contents.update(self.options)
meta = type("Meta", tuple(), meta_contents)
meta = type("Meta", (), meta_contents)
# Then, work out our bases
try:
bases = tuple(