Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adjusted inspectdb management command to yield PEP 8-compliant output…

… barring Django Coding Style exceptions.
  • Loading branch information...
commit 298a2b577ffbe7f8ed00588694c792ac9adcefbe 1 parent bc7668e
Justin Turner Arthur authored January 15, 2014 timgraham committed January 17, 2014
11  django/core/management/commands/inspectdb.py
@@ -50,12 +50,13 @@ def handle_inspection(self, options):
50 50
         yield "from __future__ import unicode_literals"
51 51
         yield ''
52 52
         yield 'from %s import models' % self.db_module
53  
-        yield ''
54 53
         known_models = []
55 54
         for table_name in connection.introspection.table_names(cursor):
56 55
             if table_name_filter is not None and callable(table_name_filter):
57 56
                 if not table_name_filter(table_name):
58 57
                     continue
  58
+            yield ''
  59
+            yield ''
59 60
             yield 'class %s(models.Model):' % table2model(table_name)
60 61
             known_models.append(table2model(table_name))
61 62
             try:
@@ -134,7 +135,7 @@ def handle_inspection(self, options):
134 135
                         for k, v in extra_params.items()])
135 136
                 field_desc += ')'
136 137
                 if comment_notes:
137  
-                    field_desc += ' # ' + ' '.join(comment_notes)
  138
+                    field_desc += '  # ' + ' '.join(comment_notes)
138 139
                 yield '    %s' % field_desc
139 140
             for meta_line in self.get_meta(table_name):
140 141
                 yield meta_line
@@ -239,7 +240,7 @@ def get_meta(self, table_name):
239 240
         to construct the inner Meta class for the model corresponding
240 241
         to the given database table name.
241 242
         """
242  
-        return ["    class Meta:",
  243
+        return ["",
  244
+                "    class Meta:",
243 245
                 "        managed = False",
244  
-                "        db_table = '%s'" % table_name,
245  
-                ""]
  246
+                "        db_table = '%s'" % table_name]
4  tests/inspectdb/tests.py
@@ -45,7 +45,7 @@ def assertFieldType(name, definition):
45 45
             self.assertEqual(definition, out_def)
46 46
 
47 47
         if not connection.features.can_introspect_autofield:
48  
-            assertFieldType('id', "models.IntegerField(primary_key=True) # AutoField?")
  48
+            assertFieldType('id', "models.IntegerField(primary_key=True)  # AutoField?")
49 49
         assertFieldType('big_int_field', "models.BigIntegerField()")
50 50
         if connection.vendor == 'mysql':
51 51
             # No native boolean type on MySQL
@@ -60,7 +60,7 @@ def assertFieldType(name, definition):
60 60
         assertFieldType('date_time_field', "models.DateTimeField()")
61 61
         if connection.vendor == 'sqlite':
62 62
             # Guessed arguments, see #5014
63  
-            assertFieldType('decimal_field', "models.DecimalField(max_digits=10, decimal_places=5) "
  63
+            assertFieldType('decimal_field', "models.DecimalField(max_digits=10, decimal_places=5)  "
64 64
                 "# max_digits and decimal_places have been guessed, as this database handles decimal fields as float")
65 65
         else:
66 66
             assertFieldType('decimal_field', "models.DecimalField(max_digits=6, decimal_places=1)")

0 notes on commit 298a2b5

Please sign in to comment.
Something went wrong with that request. Please try again.