Commit c9178ef1 authored by Berker Peksag's avatar Berker Peksag Committed by Tim Graham
Browse files

Limited lines to 119 characters in django/{contrib,db}.

Refs #23395.
parent 349471ee
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -55,7 +55,10 @@ class ContentTypeManager(models.Manager):
            # It's possible to migrate a single app before contenttypes,
            # as it's not a required initial dependency (it's contrib!)
            # Have a nice error for this.
            raise RuntimeError("Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.")
            raise RuntimeError(
                "Error creating new content types. Please make sure contenttypes "
                "is migrated before trying to migrate apps individually."
            )
        except self.model.DoesNotExist:
            # Not found in the database; we proceed to create it.  This time we
            # use get_or_create to take care of any race conditions.
+4 −2
Original line number Diff line number Diff line
@@ -162,7 +162,8 @@ class MigrationAutodetector(object):
            old_model_state = self.from_state.models[app_label, old_model_name]
            for field_name, field in old_model_state.fields:
                old_field = self.old_apps.get_model(app_label, old_model_name)._meta.get_field_by_name(field_name)[0]
                if hasattr(old_field, "rel") and getattr(old_field.rel, "through", None) and not old_field.rel.through._meta.auto_created:
                if (hasattr(old_field, "rel") and getattr(old_field.rel, "through", None)
                        and not old_field.rel.through._meta.auto_created):
                    through_key = (
                        old_field.rel.through._meta.app_label,
                        old_field.rel.through._meta.object_name.lower(),
@@ -961,7 +962,8 @@ class MigrationAutodetector(object):
            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]
            if old_model_state.options.get("order_with_respect_to", None) != new_model_state.options.get("order_with_respect_to", None):
            if (old_model_state.options.get("order_with_respect_to", None) !=
                    new_model_state.options.get("order_with_respect_to", None)):
                # Make sure it comes second if we're adding
                # (removal dependency is part of RemoveField)
                dependencies = []
+14 −5
Original line number Diff line number Diff line
@@ -37,9 +37,13 @@ class MigrationGraph(object):

    def add_dependency(self, migration, child, parent):
        if child not in self.nodes:
            raise KeyError("Migration %s dependencies reference nonexistent child node %r" % (migration, child))
            raise KeyError(
                "Migration %s dependencies reference nonexistent child node %r" % (migration, child)
            )
        if parent not in self.nodes:
            raise KeyError("Migration %s dependencies reference nonexistent parent node %r" % (migration, parent))
            raise KeyError(
                "Migration %s dependencies reference nonexistent parent node %r" % (migration, parent)
            )
        self.dependencies.setdefault(child, set()).add(parent)
        self.dependents.setdefault(parent, set()).add(child)

@@ -72,7 +76,8 @@ class MigrationGraph(object):
        """
        roots = set()
        for node in self.nodes:
            if not any(key[0] == node[0] for key in self.dependencies.get(node, set())) and (not app or app == node[0]):
            if (not any(key[0] == node[0] for key in self.dependencies.get(node, set()))
                    and (not app or app == node[0])):
                roots.add(node)
        return sorted(roots)

@@ -86,7 +91,8 @@ class MigrationGraph(object):
        """
        leaves = set()
        for node in self.nodes:
            if not any(key[0] == node[0] for key in self.dependents.get(node, set())) and (not app or app == node[0]):
            if (not any(key[0] == node[0] for key in self.dependents.get(node, set()))
                    and (not app or app == node[0])):
                leaves.add(node)
        return sorted(leaves)

@@ -116,7 +122,10 @@ class MigrationGraph(object):
        return list(OrderedSet(visited))

    def __str__(self):
        return "Graph: %s nodes, %s edges" % (len(self.nodes), sum(len(x) for x in self.dependencies.values()))
        return "Graph: %s nodes, %s edges" % (
            len(self.nodes),
            sum(len(x) for x in self.dependencies.values()),
        )

    def make_state(self, nodes=None, at_end=True, real_apps=None):
        """
+6 −2
Original line number Diff line number Diff line
@@ -106,7 +106,9 @@ class MigrationLoader(object):
                        break
                    raise
                if not hasattr(migration_module, "Migration"):
                    raise BadMigrationError("Migration %s in app %s has no Migration class" % (migration_name, app_config.label))
                    raise BadMigrationError(
                        "Migration %s in app %s has no Migration class" % (migration_name, app_config.label)
                    )
                # Ignore South-style migrations
                if hasattr(migration_module.Migration, "forwards"):
                    south_style_migrations = True
@@ -127,7 +129,9 @@ class MigrationLoader(object):
            if l == app_label and n.startswith(name_prefix):
                results.append((l, n))
        if len(results) > 1:
            raise AmbiguityError("There is more than one migration for '%s' with the prefix '%s'" % (app_label, name_prefix))
            raise AmbiguityError(
                "There is more than one migration for '%s' with the prefix '%s'" % (app_label, name_prefix)
            )
        elif len(results) == 0:
            raise KeyError("There no migrations for '%s' with the prefix '%s'" % (app_label, name_prefix))
        else:
+4 −2
Original line number Diff line number Diff line
@@ -90,7 +90,8 @@ class Migration(object):
            # there instead
            if collect_sql and not operation.reduces_to_sql:
                schema_editor.collected_sql.append("--")
                schema_editor.collected_sql.append("-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:")
                schema_editor.collected_sql.append("-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE "
                                                   "WRITTEN AS SQL:")
                schema_editor.collected_sql.append("-- %s" % operation.describe())
                schema_editor.collected_sql.append("--")
                continue
@@ -122,7 +123,8 @@ class Migration(object):
            # there instead
            if collect_sql and not operation.reduces_to_sql:
                schema_editor.collected_sql.append("--")
                schema_editor.collected_sql.append("-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:")
                schema_editor.collected_sql.append("-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE "
                                                   "WRITTEN AS SQL:")
                schema_editor.collected_sql.append("-- %s" % operation.describe())
                schema_editor.collected_sql.append("--")
                continue
Loading