From 1be3ecf90a24dce78d23d8b9bd145b241cb366b2 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 11 May 2023 12:28:52 +0100 Subject: [PATCH] - flake8 & black fixes --- django/db/models/base.py | 3 ++- tests/model_inheritance/tests.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/django/db/models/base.py b/django/db/models/base.py index d8a344e99f..930659d9ae 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -118,7 +118,8 @@ class ModelBase(type): else: new_attrs[obj_name] = obj new_class = super_new(cls, name, bases, new_attrs, **kwargs) - # update contributable_attrs with any such attributes added to new_class - these came from __init_subclass__ + # update contributable_attrs with any such attributes added to new_class. + # any such attributes came from user-defined __init_subclass__ on new_class for obj_name, obj in dict(vars(new_class)).items(): if _has_contribute_to_class(obj): contributable_attrs[obj_name] = obj diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py index b644bde8cc..7c653d6beb 100644 --- a/tests/model_inheritance/tests.py +++ b/tests/model_inheritance/tests.py @@ -255,17 +255,17 @@ class ModelInheritanceTests(TestCase): class Meta: abstract = True - def __init_subclass__(cls, author_model_cls, **kwargs): + def __init_subclass__(cls, author_cls, **kwargs): super().__init_subclass__(**kwargs) - cls.author = models.ForeignKey(author_model_cls, on_delete = models.CASCADE) + cls.author = models.ForeignKey(author_cls, on_delete=models.CASCADE) class Author(models.Model): - name = models.CharField(max_length = 256, unique = True) + name = models.CharField(max_length=256, unique=True) - class Book(BaseBookModel, author_model_cls = Author): + class Book(BaseBookModel, author_cls=Author): pass - self.assertIsInstance(Book._meta.get_field('author'), models.ForeignKey) + self.assertIsInstance(Book._meta.get_field("author"), models.ForeignKey) @isolate_apps("model_inheritance") def test_set_name(self):