From 83a36ac49a98d5d8801ed8428612e9a56aeb8699 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Thu, 28 Dec 2017 21:07:29 +0100 Subject: [PATCH] Removed unnecessary trailing commas and spaces in various code. --- django/contrib/auth/decorators.py | 2 +- django/contrib/auth/mixins.py | 2 +- django/contrib/gis/db/models/fields.py | 2 +- django/core/checks/registry.py | 2 +- django/core/management/commands/inspectdb.py | 2 +- .../management/commands/makemigrations.py | 2 +- django/core/management/commands/migrate.py | 2 +- .../management/commands/squashmigrations.py | 2 +- django/db/migrations/autodetector.py | 2 +- django/db/migrations/exceptions.py | 2 +- django/db/migrations/graph.py | 8 +++---- django/db/migrations/operations/models.py | 6 ++--- django/db/migrations/state.py | 2 +- docs/conf.py | 2 +- docs/ref/contrib/flatpages.txt | 2 +- docs/ref/contrib/syndication.txt | 2 +- docs/topics/auth/customizing.txt | 2 +- tests/admin_filters/tests.py | 6 ++--- tests/admin_ordering/models.py | 2 +- tests/admin_views/admin.py | 6 ++--- tests/check_framework/test_security.py | 2 +- tests/check_framework/tests.py | 4 ++-- tests/flatpages_tests/test_forms.py | 2 +- tests/gis_tests/gdal_tests/test_raster.py | 8 +++---- tests/gis_tests/geos_tests/test_geos.py | 2 +- tests/i18n/tests.py | 2 +- tests/lookup/models.py | 4 ++-- tests/m2m_through/tests.py | 6 ++--- tests/migrations/test_autodetector.py | 22 +++++++++---------- tests/migrations/test_executor.py | 8 +++---- tests/migrations/test_graph.py | 2 +- tests/migrations/test_operations.py | 4 ++-- tests/migrations/test_optimizer.py | 8 +++---- tests/migrations/test_state.py | 12 +++++----- tests/model_formsets_regress/tests.py | 2 +- tests/modeladmin/test_checks.py | 8 +++---- tests/null_fk_ordering/models.py | 4 ++-- tests/queries/models.py | 4 ++-- tests/queries/tests.py | 6 ++--- tests/queryset_pickle/tests.py | 2 +- tests/staticfiles_tests/test_forms.py | 2 +- tests/validation/test_unique.py | 2 +- 42 files changed, 87 insertions(+), 87 deletions(-) diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py index 55a23ade56..53f62e8371 100644 --- a/django/contrib/auth/decorators.py +++ b/django/contrib/auth/decorators.py @@ -59,7 +59,7 @@ def permission_required(perm, login_url=None, raise_exception=False): """ def check_perms(user): if isinstance(perm, str): - perms = (perm, ) + perms = (perm,) else: perms = perm # First check if the user has the permission (even anon users) diff --git a/django/contrib/auth/mixins.py b/django/contrib/auth/mixins.py index c6011225c4..a06e04dadd 100644 --- a/django/contrib/auth/mixins.py +++ b/django/contrib/auth/mixins.py @@ -67,7 +67,7 @@ class PermissionRequiredMixin(AccessMixin): '{0}.get_permission_required().'.format(self.__class__.__name__) ) if isinstance(self.permission_required, str): - perms = (self.permission_required, ) + perms = (self.permission_required,) else: perms = self.permission_required return perms diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py index 12af07b9b7..0cd644ddd9 100644 --- a/django/contrib/gis/db/models/fields.py +++ b/django/contrib/gis/db/models/fields.py @@ -369,7 +369,7 @@ class RasterField(BaseSpatialField): band_index = int(name) return type( 'SpecificRasterBandTransform', - (RasterBandTransform, ), + (RasterBandTransform,), {'band_index': band_index} ) except ValueError: diff --git a/django/core/checks/registry.py b/django/core/checks/registry.py index c580c80483..9d44940016 100644 --- a/django/core/checks/registry.py +++ b/django/core/checks/registry.py @@ -52,7 +52,7 @@ class CheckRegistry: return inner(check) else: if check: - tags += (check, ) + tags += (check,) return inner def run_checks(self, app_configs=None, tags=None, include_deployment_checks=False): diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py index 4d453ea86b..c502b34b51 100644 --- a/django/core/management/commands/inspectdb.py +++ b/django/core/management/commands/inspectdb.py @@ -10,7 +10,7 @@ from django.db.models.constants import LOOKUP_SEP class Command(BaseCommand): help = "Introspects the database tables in the given database and outputs a Django model module." requires_system_checks = False - stealth_options = ('table_name_filter', ) + stealth_options = ('table_name_filter',) db_module = 'django.db' def add_arguments(self, parser): diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py index 777577f148..96b9b2adbc 100644 --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -276,7 +276,7 @@ class Command(BaseCommand): biggest_number = max(x for x in numbers if x is not None) except ValueError: biggest_number = 1 - subclass = type("Migration", (Migration, ), { + subclass = type("Migration", (Migration,), { "dependencies": [(app_label, migration.name) for migration in merge_migrations], }) migration_name = "%04i_%s" % ( diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py index e549b7200b..7ca728fc97 100644 --- a/django/core/management/commands/migrate.py +++ b/django/core/management/commands/migrate.py @@ -148,7 +148,7 @@ class Command(BaseCommand): else: if targets[0][1] is None: self.stdout.write(self.style.MIGRATE_LABEL( - " Unapply all migrations: ") + "%s" % (targets[0][0], ) + " Unapply all migrations: ") + "%s" % (targets[0][0],) ) else: self.stdout.write(self.style.MIGRATE_LABEL( diff --git a/django/core/management/commands/squashmigrations.py b/django/core/management/commands/squashmigrations.py index 60faf6cc1f..68c2a4ea5d 100644 --- a/django/core/management/commands/squashmigrations.py +++ b/django/core/management/commands/squashmigrations.py @@ -153,7 +153,7 @@ class Command(BaseCommand): replaces.append((migration.app_label, migration.name)) # Make a new migration with those operations - subclass = type("Migration", (migrations.Migration, ), { + subclass = type("Migration", (migrations.Migration,), { "dependencies": dependencies, "operations": new_operations, "replaces": replaces, diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index dfbadc9d22..1dce17be6e 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -419,7 +419,7 @@ class MigrationAutodetector: ) # Unknown dependency. Raise an error. else: - raise ValueError("Can't handle dependency %r" % (dependency, )) + raise ValueError("Can't handle dependency %r" % (dependency,)) def add_operation(self, app_label, operation, dependencies=None, beginning=False): # Dependencies are (app_label, model_name, field_name, create/delete as True/False) diff --git a/django/db/migrations/exceptions.py b/django/db/migrations/exceptions.py index c2e9ceb28c..f389701d67 100644 --- a/django/db/migrations/exceptions.py +++ b/django/db/migrations/exceptions.py @@ -43,7 +43,7 @@ class NodeNotFoundError(LookupError): return self.message def __repr__(self): - return "NodeNotFoundError(%r)" % (self.node, ) + return "NodeNotFoundError(%r)" % (self.node,) class MigrationSchemaMissing(DatabaseError): diff --git a/django/db/migrations/graph.py b/django/db/migrations/graph.py index 4bb66b7615..a2ad984e73 100644 --- a/django/db/migrations/graph.py +++ b/django/db/migrations/graph.py @@ -178,7 +178,7 @@ class MigrationGraph: except KeyError as err: raise NodeNotFoundError( "Unable to find replacement node %r. It was either never added" - " to the migration graph, or has been removed." % (replacement, ), + " to the migration graph, or has been removed." % (replacement,), replacement ) from err for replaced_key in replaced: @@ -214,7 +214,7 @@ class MigrationGraph: except KeyError as err: raise NodeNotFoundError( "Unable to remove replacement node %r. It was either never added" - " to the migration graph, or has been removed already." % (replacement, ), + " to the migration graph, or has been removed already." % (replacement,), replacement ) from err replaced_nodes = set() @@ -256,7 +256,7 @@ class MigrationGraph: follow if applying the migrations to a database. """ if target not in self.nodes: - raise NodeNotFoundError("Node %r not a valid node" % (target, ), target) + raise NodeNotFoundError("Node %r not a valid node" % (target,), target) # Use parent.key instead of parent to speed up the frequent hashing in ensure_not_cyclic self.ensure_not_cyclic(target, lambda x: (parent.key for parent in self.node_map[x].parents)) self.cached = True @@ -275,7 +275,7 @@ class MigrationGraph: would follow if removing the migrations from a database. """ if target not in self.nodes: - raise NodeNotFoundError("Node %r not a valid node" % (target, ), target) + raise NodeNotFoundError("Node %r not a valid node" % (target,), target) # Use child.key instead of child to speed up the frequent hashing in ensure_not_cyclic self.ensure_not_cyclic(target, lambda x: (child.key for child in self.node_map[x].children)) self.cached = True diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py index 24d71b17c8..fcdf752f6d 100644 --- a/django/db/migrations/operations/models.py +++ b/django/db/migrations/operations/models.py @@ -249,7 +249,7 @@ class DeleteModel(ModelOperation): schema_editor.create_model(model) def describe(self): - return "Delete model %s" % (self.name, ) + return "Delete model %s" % self.name class RenameModel(ModelOperation): @@ -701,7 +701,7 @@ class AlterModelOptions(ModelOptionOperation): pass def describe(self): - return "Change Meta options on %s" % (self.name, ) + return "Change Meta options on %s" % self.name class AlterModelManagers(ModelOptionOperation): @@ -732,7 +732,7 @@ class AlterModelManagers(ModelOptionOperation): pass def describe(self): - return "Change managers on %s" % (self.name, ) + return "Change managers on %s" % self.name class IndexOperation(Operation): diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py index 7d072175b1..f41d1edf2c 100644 --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -362,7 +362,7 @@ class ModelState: self.fields = fields self.options = options or {} self.options.setdefault('indexes', []) - self.bases = bases or (models.Model, ) + self.bases = bases or (models.Model,) self.managers = managers or [] # Sanity-check that fields is NOT a dict. It must be ordered. if isinstance(self.fields, dict): diff --git a/docs/conf.py b/docs/conf.py index 3e346fda12..639438a3ac 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -284,7 +284,7 @@ man_pages = [( 'Utility script for the Django Web framework', ['Django Software Foundation'], 1 -), ] +)] # -- Options for Texinfo output ------------------------------------------------ diff --git a/docs/ref/contrib/flatpages.txt b/docs/ref/contrib/flatpages.txt index 5d34ad6bea..827473a2a9 100644 --- a/docs/ref/contrib/flatpages.txt +++ b/docs/ref/contrib/flatpages.txt @@ -193,7 +193,7 @@ registering a custom ``ModelAdmin`` for ``FlatPage``:: fieldsets = ( (None, {'fields': ('url', 'title', 'content', 'sites')}), (_('Advanced options'), { - 'classes': ('collapse', ), + 'classes': ('collapse',), 'fields': ( 'enable_comments', 'registration_required', diff --git a/docs/ref/contrib/syndication.txt b/docs/ref/contrib/syndication.txt index 8fa5965a72..421bceaec1 100644 --- a/docs/ref/contrib/syndication.txt +++ b/docs/ref/contrib/syndication.txt @@ -1029,7 +1029,7 @@ attributes. Thus, you can subclass the appropriate feed generator class .. _georss: http://georss.org/ .. _itunes podcast format: https://www.apple.com/itunes/podcasts/specs.html -``SyndicationFeed.root_attributes(self, )`` +``SyndicationFeed.root_attributes(self)`` Return a ``dict`` of attributes to add to the root feed element (``feed``/``channel``). diff --git a/docs/topics/auth/customizing.txt b/docs/topics/auth/customizing.txt index c9909f5924..ce518b41be 100644 --- a/docs/topics/auth/customizing.txt +++ b/docs/topics/auth/customizing.txt @@ -348,7 +348,7 @@ add it to a ``UserAdmin`` class which is registered with the # Define a new User admin class UserAdmin(BaseUserAdmin): - inlines = (EmployeeInline, ) + inlines = (EmployeeInline,) # Re-register UserAdmin admin.site.unregister(User) diff --git a/tests/admin_filters/tests.py b/tests/admin_filters/tests.py index 4a11c1a96b..200c8c8db1 100644 --- a/tests/admin_filters/tests.py +++ b/tests/admin_filters/tests.py @@ -229,15 +229,15 @@ class EmployeeAdmin(ModelAdmin): class DepartmentFilterEmployeeAdmin(EmployeeAdmin): - list_filter = [DepartmentListFilterLookupWithNonStringValue, ] + list_filter = [DepartmentListFilterLookupWithNonStringValue] class DepartmentFilterUnderscoredEmployeeAdmin(EmployeeAdmin): - list_filter = [DepartmentListFilterLookupWithUnderscoredParameter, ] + list_filter = [DepartmentListFilterLookupWithUnderscoredParameter] class DepartmentFilterDynamicValueBookAdmin(EmployeeAdmin): - list_filter = [DepartmentListFilterLookupWithDynamicValue, ] + list_filter = [DepartmentListFilterLookupWithDynamicValue] class BookmarkAdminGenericRelation(ModelAdmin): diff --git a/tests/admin_ordering/models.py b/tests/admin_ordering/models.py index b8098b9bcc..fbddeaa283 100644 --- a/tests/admin_ordering/models.py +++ b/tests/admin_ordering/models.py @@ -27,7 +27,7 @@ class SongInlineDefaultOrdering(admin.StackedInline): class SongInlineNewOrdering(admin.StackedInline): model = Song - ordering = ('duration', ) + ordering = ('duration',) class DynOrderingBandAdmin(admin.ModelAdmin): diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index 2c58baea7a..1e4124fca5 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -568,7 +568,7 @@ class StoryForm(forms.ModelForm): class StoryAdmin(admin.ModelAdmin): list_display = ('id', 'title', 'content') list_display_links = ('title',) # 'id' not in list_display_links - list_editable = ('content', ) + list_editable = ('content',) form = StoryForm ordering = ['-id'] @@ -576,7 +576,7 @@ class StoryAdmin(admin.ModelAdmin): class OtherStoryAdmin(admin.ModelAdmin): list_display = ('id', 'title', 'content') list_display_links = ('title', 'id') # 'id' in list_display_links - list_editable = ('content', ) + list_editable = ('content',) ordering = ['-id'] @@ -748,7 +748,7 @@ def callable_on_unknown(obj): class AttributeErrorRaisingAdmin(admin.ModelAdmin): - list_display = [callable_on_unknown, ] + list_display = [callable_on_unknown] class CustomManagerAdmin(admin.ModelAdmin): diff --git a/tests/check_framework/test_security.py b/tests/check_framework/test_security.py index 370fca533b..cfc90f95e9 100644 --- a/tests/check_framework/test_security.py +++ b/tests/check_framework/test_security.py @@ -518,6 +518,6 @@ class CheckAllowedHostsTest(SimpleTestCase): def test_allowed_hosts_empty(self): self.assertEqual(self.func(None), [base.W020]) - @override_settings(ALLOWED_HOSTS=['.example.com', ]) + @override_settings(ALLOWED_HOSTS=['.example.com']) def test_allowed_hosts_set(self): self.assertEqual(self.func(None), []) diff --git a/tests/check_framework/tests.py b/tests/check_framework/tests.py index abb4298c65..061ead9d23 100644 --- a/tests/check_framework/tests.py +++ b/tests/check_framework/tests.py @@ -30,10 +30,10 @@ class SystemCheckFrameworkTests(SimpleTestCase): return [1, 2, 3] def f2(**kwargs): - return [4, ] + return [4] def f3(**kwargs): - return [5, ] + return [5] calls = [0] diff --git a/tests/flatpages_tests/test_forms.py b/tests/flatpages_tests/test_forms.py index 9ed678fdc2..2a4bb0679a 100644 --- a/tests/flatpages_tests/test_forms.py +++ b/tests/flatpages_tests/test_forms.py @@ -6,7 +6,7 @@ from django.test import TestCase, modify_settings, override_settings from django.utils import translation -@modify_settings(INSTALLED_APPS={'append': ['django.contrib.flatpages', ]}) +@modify_settings(INSTALLED_APPS={'append': ['django.contrib.flatpages']}) @override_settings(SITE_ID=1) class FlatpageAdminFormTests(TestCase): diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py index 219600fb6a..936f9f1204 100644 --- a/tests/gis_tests/gdal_tests/test_raster.py +++ b/tests/gis_tests/gdal_tests/test_raster.py @@ -256,7 +256,7 @@ class GDALRasterTests(SimpleTestCase): if numpy: result = result.flatten().tolist() # All band data is equal to nodata value. - self.assertEqual(result, [23, ] * 4) + self.assertEqual(result, [23] * 4) def test_set_nodata_none_on_raster_creation(self): if GDAL_VERSION < (2, 1): @@ -299,7 +299,7 @@ class GDALRasterTests(SimpleTestCase): }) # Set metadata on raster and on a band. metadata = { - 'DEFAULT': {'OWNER': 'Django', 'VERSION': '1.0', 'AREA_OR_POINT': 'Point', }, + 'DEFAULT': {'OWNER': 'Django', 'VERSION': '1.0', 'AREA_OR_POINT': 'Point'}, } source.metadata = metadata source.bands[0].metadata = metadata @@ -307,13 +307,13 @@ class GDALRasterTests(SimpleTestCase): self.assertEqual(source.bands[0].metadata['DEFAULT'], metadata['DEFAULT']) # Update metadata on raster. metadata = { - 'DEFAULT': {'VERSION': '2.0', }, + 'DEFAULT': {'VERSION': '2.0'}, } source.metadata = metadata self.assertEqual(source.metadata['DEFAULT']['VERSION'], '2.0') # Remove metadata on raster. metadata = { - 'DEFAULT': {'OWNER': None, }, + 'DEFAULT': {'OWNER': None}, } source.metadata = metadata self.assertNotIn('OWNER', source.metadata['DEFAULT']) diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py index 955bb6c5d2..db8c44d758 100644 --- a/tests/gis_tests/geos_tests/test_geos.py +++ b/tests/gis_tests/geos_tests/test_geos.py @@ -1264,7 +1264,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin): mp = MultiPolygon(p1, p2) path, args, kwargs = mp.deconstruct() self.assertEqual(path, 'django.contrib.gis.geos.collections.MultiPolygon') - self.assertEqual(args, (p1, p2, )) + self.assertEqual(args, (p1, p2)) self.assertEqual(kwargs, {}) poly = Polygon(((0, 0), (0, 1), (1, 1), (0, 0))) diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index 752940b614..5fb710faf8 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -1142,7 +1142,7 @@ class MiscTests(SimpleTestCase): ('en; q=1.0, * ; q=0.5', [('en', 1.0), ('*', 0.5)]), # Bad headers ('en-gb;q=1.0000', []), - ('en;q=0.1234', [], ), + ('en;q=0.1234', []), ('en;q=.2', []), ('abcdefghi-au', []), ('**', []), diff --git a/tests/lookup/models.py b/tests/lookup/models.py index d58d863885..ef5e7dfb0e 100644 --- a/tests/lookup/models.py +++ b/tests/lookup/models.py @@ -19,7 +19,7 @@ class Author(models.Model): name = models.CharField(max_length=100) class Meta: - ordering = ('name', ) + ordering = ('name',) class Article(models.Model): @@ -40,7 +40,7 @@ class Tag(models.Model): name = models.CharField(max_length=100) class Meta: - ordering = ('name', ) + ordering = ('name',) class NulledTextField(models.TextField): diff --git a/tests/m2m_through/tests.py b/tests/m2m_through/tests.py index 5be6ef72d0..930f5e848c 100644 --- a/tests/m2m_through/tests.py +++ b/tests/m2m_through/tests.py @@ -87,7 +87,7 @@ class M2mThroughTests(TestCase): self.assertQuerysetEqual( self.rock.members.all(), - ['Jim', ], + ['Jim'], attrgetter("name") ) @@ -156,7 +156,7 @@ class M2mThroughTests(TestCase): self.assertQuerysetEqual( self.bob.group_set.all(), - ['Rock', ], + ['Rock'], attrgetter('name') ) @@ -192,7 +192,7 @@ class M2mThroughTests(TestCase): self.assertQuerysetEqual( Group.objects.filter(members__name='Bob'), - ['Roll', ], + ['Roll'], attrgetter("name") ) diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py index a111b8f70d..bc828203f8 100644 --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -237,13 +237,13 @@ class AutodetectorTests(TestCase): author_proxy_options = ModelState("testapp", "AuthorProxy", [], { "proxy": True, "verbose_name": "Super Author", - }, ("testapp.author", )) - author_proxy_notproxy = ModelState("testapp", "AuthorProxy", [], {}, ("testapp.author", )) - author_proxy_third = ModelState("thirdapp", "AuthorProxy", [], {"proxy": True}, ("testapp.author", )) - author_proxy_third_notproxy = ModelState("thirdapp", "AuthorProxy", [], {}, ("testapp.author", )) - author_proxy_proxy = ModelState("testapp", "AAuthorProxyProxy", [], {"proxy": True}, ("testapp.authorproxy", )) - author_unmanaged = ModelState("testapp", "AuthorUnmanaged", [], {"managed": False}, ("testapp.author", )) - author_unmanaged_managed = ModelState("testapp", "AuthorUnmanaged", [], {}, ("testapp.author", )) + }, ("testapp.author",)) + author_proxy_notproxy = ModelState("testapp", "AuthorProxy", [], {}, ("testapp.author",)) + author_proxy_third = ModelState("thirdapp", "AuthorProxy", [], {"proxy": True}, ("testapp.author",)) + author_proxy_third_notproxy = ModelState("thirdapp", "AuthorProxy", [], {}, ("testapp.author",)) + author_proxy_proxy = ModelState("testapp", "AAuthorProxyProxy", [], {"proxy": True}, ("testapp.authorproxy",)) + author_unmanaged = ModelState("testapp", "AuthorUnmanaged", [], {"managed": False}, ("testapp.author",)) + author_unmanaged_managed = ModelState("testapp", "AuthorUnmanaged", [], {}, ("testapp.author",)) author_unmanaged_default_pk = ModelState("testapp", "Author", [("id", models.AutoField(primary_key=True))]) author_unmanaged_custom_pk = ModelState("testapp", "Author", [ ("pk_field", models.IntegerField(primary_key=True)), @@ -430,14 +430,14 @@ class AutodetectorTests(TestCase): custom_user = ModelState("thirdapp", "CustomUser", [ ("id", models.AutoField(primary_key=True)), ("username", models.CharField(max_length=255)), - ], bases=(AbstractBaseUser, )) + ], bases=(AbstractBaseUser,)) custom_user_no_inherit = ModelState("thirdapp", "CustomUser", [ ("id", models.AutoField(primary_key=True)), ("username", models.CharField(max_length=255)), ]) aardvark = ModelState("thirdapp", "Aardvark", [("id", models.AutoField(primary_key=True))]) aardvark_testapp = ModelState("testapp", "Aardvark", [("id", models.AutoField(primary_key=True))]) - aardvark_based_on_author = ModelState("testapp", "Aardvark", [], bases=("testapp.Author", )) + aardvark_based_on_author = ModelState("testapp", "Aardvark", [], bases=("testapp.Author",)) aardvark_pk_fk_author = ModelState("testapp", "Aardvark", [ ("id", models.OneToOneField("testapp.Author", models.CASCADE, primary_key=True)), ]) @@ -2071,7 +2071,7 @@ class AutodetectorTests(TestCase): tenant = ModelState("a", "Tenant", [ ("id", models.AutoField(primary_key=True)), ("primary_address", models.ForeignKey("b.Address", models.CASCADE))], - bases=(AbstractBaseUser, ) + bases=(AbstractBaseUser,) ) address = ModelState("b", "Address", [ ("id", models.AutoField(primary_key=True)), @@ -2105,7 +2105,7 @@ class AutodetectorTests(TestCase): tenant = ModelState("b", "Tenant", [ ("id", models.AutoField(primary_key=True)), ("primary_address", models.ForeignKey("a.Address", models.CASCADE))], - bases=(AbstractBaseUser, ) + bases=(AbstractBaseUser,) ) changes = self.get_changes([], [address, tenant]) # Right number/type of migrations? diff --git a/tests/migrations/test_executor.py b/tests/migrations/test_executor.py index fdbc724faf..71447478ad 100644 --- a/tests/migrations/test_executor.py +++ b/tests/migrations/test_executor.py @@ -554,14 +554,14 @@ class ExecutorTests(MigrationTestBase): migrations = executor.loader.graph.nodes expected = [ - ("render_start", ), - ("render_success", ), + ("render_start",), + ("render_success",), ("apply_start", migrations['migrations', '0001_initial'], False), ("apply_success", migrations['migrations', '0001_initial'], False), ("apply_start", migrations['migrations', '0002_second'], False), ("apply_success", migrations['migrations', '0002_second'], False), - ("render_start", ), - ("render_success", ), + ("render_start",), + ("render_success",), ("unapply_start", migrations['migrations', '0002_second'], False), ("unapply_success", migrations['migrations', '0002_second'], False), ("unapply_start", migrations['migrations', '0001_initial'], False), diff --git a/tests/migrations/test_graph.py b/tests/migrations/test_graph.py index 799ee916fc..d4ab3685a9 100644 --- a/tests/migrations/test_graph.py +++ b/tests/migrations/test_graph.py @@ -147,7 +147,7 @@ class GraphTests(SimpleTestCase): graph.add_dependency("app_b.0001", ("app_b", "0001"), ("app_a", "0003")) # Test whole graph with self.assertRaises(CircularDependencyError): - graph.forwards_plan(("app_a", "0003"), ) + graph.forwards_plan(("app_a", "0003")) def test_circular_graph_2(self): graph = MigrationGraph() diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index d953ea20aa..fb429e19cf 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -409,7 +409,7 @@ class OperationTests(OperationTestBase): "ProxyPony", [], options={"proxy": True}, - bases=("test_crprmo.Pony", ), + bases=("test_crprmo.Pony",), ) self.assertEqual(operation.describe(), "Create proxy model ProxyPony") new_state = project_state.clone() @@ -443,7 +443,7 @@ class OperationTests(OperationTestBase): "UnmanagedPony", [], options={"proxy": True}, - bases=("test_crummo.Pony", ), + bases=("test_crummo.Pony",), ) self.assertEqual(operation.describe(), "Create proxy model UnmanagedPony") new_state = project_state.clone() diff --git a/tests/migrations/test_optimizer.py b/tests/migrations/test_optimizer.py index 40cc50b33b..0a13ef290f 100644 --- a/tests/migrations/test_optimizer.py +++ b/tests/migrations/test_optimizer.py @@ -243,7 +243,7 @@ class OptimizerTests(SimpleTestCase): self.assertDoesNotOptimize( [ migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]), - migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )), + migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo",)), migrations.DeleteModel("Foo"), ], ) @@ -252,11 +252,11 @@ class OptimizerTests(SimpleTestCase): self.assertOptimizesTo( [ migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]), - migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )), + migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo",)), migrations.DeleteModel("Foo"), ], [ - migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )), + migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo",)), ], app_label="otherapp", ) @@ -264,7 +264,7 @@ class OptimizerTests(SimpleTestCase): self.assertDoesNotOptimize( [ migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]), - migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )), + migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo",)), migrations.DeleteModel("Foo"), ], app_label="testapp", diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py index 9110e8d447..255e14beff 100644 --- a/tests/migrations/test_state.py +++ b/tests/migrations/test_state.py @@ -129,7 +129,7 @@ class StateTests(SimpleTestCase): author_state.options, {"unique_together": {("name", "bio")}, "index_together": {("bio", "age")}, "indexes": []} ) - self.assertEqual(author_state.bases, (models.Model, )) + self.assertEqual(author_state.bases, (models.Model,)) self.assertEqual(book_state.app_label, "migrations") self.assertEqual(book_state.name, "Book") @@ -141,18 +141,18 @@ class StateTests(SimpleTestCase): book_state.options, {"verbose_name": "tome", "db_table": "test_tome", "indexes": [book_index]}, ) - self.assertEqual(book_state.bases, (models.Model, )) + self.assertEqual(book_state.bases, (models.Model,)) self.assertEqual(author_proxy_state.app_label, "migrations") self.assertEqual(author_proxy_state.name, "AuthorProxy") self.assertEqual(author_proxy_state.fields, []) self.assertEqual(author_proxy_state.options, {"proxy": True, "ordering": ["name"], "indexes": []}) - self.assertEqual(author_proxy_state.bases, ("migrations.author", )) + self.assertEqual(author_proxy_state.bases, ("migrations.author",)) self.assertEqual(sub_author_state.app_label, "migrations") self.assertEqual(sub_author_state.name, "SubAuthor") self.assertEqual(len(sub_author_state.fields), 2) - self.assertEqual(sub_author_state.bases, ("migrations.author", )) + self.assertEqual(sub_author_state.bases, ("migrations.author",)) # The default manager is used in migrations self.assertEqual([name for name, mgr in food_state.managers], ['food_mgr']) @@ -1003,7 +1003,7 @@ class ModelStateTests(SimpleTestCase): self.assertIs(author_state.fields[2][1].null, False) self.assertIs(author_state.fields[3][1].null, True) self.assertEqual(author_state.options, {'swappable': 'TEST_SWAPPABLE_MODEL', 'indexes': []}) - self.assertEqual(author_state.bases, (models.Model, )) + self.assertEqual(author_state.bases, (models.Model,)) self.assertEqual(author_state.managers, []) @override_settings(TEST_SWAPPABLE_MODEL='migrations.SomeFakeModel') @@ -1049,7 +1049,7 @@ class ModelStateTests(SimpleTestCase): station_state.options, {'abstract': False, 'swappable': 'TEST_SWAPPABLE_MODEL', 'indexes': []} ) - self.assertEqual(station_state.bases, ('migrations.searchablelocation', )) + self.assertEqual(station_state.bases, ('migrations.searchablelocation',)) self.assertEqual(station_state.managers, []) @override_settings(TEST_SWAPPABLE_MODEL='migrations.SomeFakeModel') diff --git a/tests/model_formsets_regress/tests.py b/tests/model_formsets_regress/tests.py index 26ab9c1ae9..ec58a6382a 100644 --- a/tests/model_formsets_regress/tests.py +++ b/tests/model_formsets_regress/tests.py @@ -291,7 +291,7 @@ class FormsetTests(TestCase): data = {'test-TOTAL_FORMS': '1', 'test-INITIAL_FORMS': '0', 'test-MAX_NUM_FORMS': '', - 'test-0-name': 'Random Place', } + 'test-0-name': 'Random Place'} with self.assertNumQueries(1): formset = Formset(data, prefix="test") formset.save() diff --git a/tests/modeladmin/test_checks.py b/tests/modeladmin/test_checks.py index 5559a8fe3c..f268fead15 100644 --- a/tests/modeladmin/test_checks.py +++ b/tests/modeladmin/test_checks.py @@ -625,7 +625,7 @@ class ListFilterTests(CheckTestCase): return 'awesomeness' def get_choices(self, request): - return (('bit', 'A bit awesome'), ('very', 'Very awesome'), ) + return (('bit', 'A bit awesome'), ('very', 'Very awesome')) def get_queryset(self, cl, qs): return qs @@ -655,7 +655,7 @@ class ListFilterTests(CheckTestCase): return 'awesomeness' def get_choices(self, request): - return (('bit', 'A bit awesome'), ('very', 'Very awesome'), ) + return (('bit', 'A bit awesome'), ('very', 'Very awesome')) def get_queryset(self, cl, qs): return qs @@ -1248,10 +1248,10 @@ class AutocompleteFieldsTests(CheckTestCase): def test_autocomplete_is_onetoone(self): class UserAdmin(ModelAdmin): - search_fields = ('name', ) + search_fields = ('name',) class Admin(ModelAdmin): - autocomplete_fields = ('best_friend', ) + autocomplete_fields = ('best_friend',) site = AdminSite() site.register(User, UserAdmin) diff --git a/tests/null_fk_ordering/models.py b/tests/null_fk_ordering/models.py index a7938cec54..368a47044e 100644 --- a/tests/null_fk_ordering/models.py +++ b/tests/null_fk_ordering/models.py @@ -18,10 +18,10 @@ class Article(models.Model): author = models.ForeignKey(Author, models.SET_NULL, null=True) def __str__(self): - return 'Article titled: %s' % (self.title, ) + return 'Article titled: %s' % self.title class Meta: - ordering = ['author__name', ] + ordering = ['author__name'] # These following 4 models represent a far more complex ordering case. diff --git a/tests/queries/models.py b/tests/queries/models.py index c3f5125498..902fd55c05 100644 --- a/tests/queries/models.py +++ b/tests/queries/models.py @@ -579,7 +579,7 @@ class Order(models.Model): id = models.IntegerField(primary_key=True) class Meta: - ordering = ('pk', ) + ordering = ('pk',) def __str__(self): return '%s' % self.pk @@ -590,7 +590,7 @@ class OrderItem(models.Model): status = models.IntegerField() class Meta: - ordering = ('pk', ) + ordering = ('pk',) def __str__(self): return '%s' % self.pk diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 668b07361a..ec50194e3a 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -2351,11 +2351,11 @@ class QuerySetSupportsPythonIdioms(TestCase): def test_slicing_cannot_filter_queryset_once_sliced(self): with self.assertRaisesMessage(AssertionError, "Cannot filter a query once a slice has been taken."): - Article.objects.all()[0:5].filter(id=1, ) + Article.objects.all()[0:5].filter(id=1) def test_slicing_cannot_reorder_queryset_once_sliced(self): with self.assertRaisesMessage(AssertionError, "Cannot reorder a query once a slice has been taken."): - Article.objects.all()[0:5].order_by('id', ) + Article.objects.all()[0:5].order_by('id') def test_slicing_cannot_combine_queries_once_sliced(self): with self.assertRaisesMessage(AssertionError, "Cannot combine queries once a slice has been taken."): @@ -3581,7 +3581,7 @@ class RelatedLookupTypeTests(TestCase): When passing proxy model objects, child objects, or parent objects, lookups work fine. """ - out_a = ['', ] + out_a = [''] out_b = ['', ''] out_c = [''] diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py index 27f509a9c1..7eec47379c 100644 --- a/tests/queryset_pickle/tests.py +++ b/tests/queryset_pickle/tests.py @@ -102,7 +102,7 @@ class PickleabilityTestCase(TestCase): def test_model_pickle_dynamic(self): class Meta: proxy = True - dynclass = type("DynamicEventSubclass", (Event, ), {'Meta': Meta, '__module__': Event.__module__}) + dynclass = type("DynamicEventSubclass", (Event,), {'Meta': Meta, '__module__': Event.__module__}) original = dynclass(pk=1) dumped = pickle.dumps(original) reloaded = pickle.loads(dumped) diff --git a/tests/staticfiles_tests/test_forms.py b/tests/staticfiles_tests/test_forms.py index 4666520bc1..ec9f069ed8 100644 --- a/tests/staticfiles_tests/test_forms.py +++ b/tests/staticfiles_tests/test_forms.py @@ -13,7 +13,7 @@ class StaticTestStorage(storage.StaticFilesStorage): @override_settings( STATIC_URL='http://media.example.com/static/', - INSTALLED_APPS=('django.contrib.staticfiles', ), + INSTALLED_APPS=('django.contrib.staticfiles',), STATICFILES_STORAGE='staticfiles_tests.test_forms.StaticTestStorage', ) class StaticFilesFormsMediaTestCase(SimpleTestCase): diff --git a/tests/validation/test_unique.py b/tests/validation/test_unique.py index 002e568ae9..88eb94a54e 100644 --- a/tests/validation/test_unique.py +++ b/tests/validation/test_unique.py @@ -28,7 +28,7 @@ class GetUniqueCheckTests(unittest.TestCase): self.assertEqual( ([(UniqueTogetherModel, ('ifield', 'cfield')), (UniqueTogetherModel, ('ifield', 'efield')), - (UniqueTogetherModel, ('id',)), ], + (UniqueTogetherModel, ('id',))], []), m._get_unique_checks() )