Opened 2 years ago

Closed 2 years ago

#29093 closed Cleanup/optimization (fixed)

django/db/models/base.py:ModelBase.__new__() utilize 'or'

Reported by: Дилян Палаузов Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

diff --git a/django/db/models/base.py b/django/db/models/base.py
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -78,10 +78,7 @@ class ModelBase(type):
         new_class = super_new(cls, name, bases, new_attrs, **kwargs)
         attr_meta = attrs.pop('Meta', None)
         abstract = getattr(attr_meta, 'abstract', False)
-        if not attr_meta:
-            meta = getattr(new_class, 'Meta', None)
-        else:
-            meta = attr_meta
+        meta = attr_meta or getattr(new_class, 'Meta', None)
         base_meta = getattr(new_class, '_meta', None)
 
         app_label = None

Change History (1)

comment:1 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In f427ffcc:

Fixed #29093 -- Simplified a few lines in ModelBase.new().

Note: See TracTickets for help on using tickets.
Back to Top