From 3f3747a2fe660d08bb8af4f079fb2f4b0c3540eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alice=20Bevan=E2=80=93McGregor?= Date: Tue, 13 Oct 2015 21:59:46 -0400 Subject: [PATCH] Minor formatting tweaks and additional comments. --- mongoengine/base/fields.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mongoengine/base/fields.py b/mongoengine/base/fields.py index 3427a094..9f054a2b 100644 --- a/mongoengine/base/fields.py +++ b/mongoengine/base/fields.py @@ -82,13 +82,14 @@ class BaseField(object): self.sparse = sparse self._owner_document = None + # Detect and report conflicts between metadata and base properties. conflicts = set(dir(self)).intersect(kwargs) if conflicts: raise TypeError("%s already has attribute(s): %s" % ( - self.__class__.__name__, - ', '.join(conflicts) - )) - + self.__class__.__name__, ', '.join(conflicts) )) + + # Assign metadata to the instance + # This efficient method is available because no __slots__ are defined. self.__dict__.update(kwargs) # Adjust the appropriate creation counter, and save our local copy.