Skip to content

Commit 1ca68f4

Browse files
authored
Replace the shared _attributes field with a per-subclass fields. (#324)
1 parent f6f67ae commit 1ca68f4

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

pynamodb/attributes.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
PynamoDB attributes
33
"""
44
import six
5-
from six import add_metaclass
65
import json
76
from base64 import b64encode, b64decode
87
from datetime import datetime
@@ -102,7 +101,6 @@ def _get_attribute_value(self, value):
102101

103102
class AttributeContainer(object):
104103

105-
_attributes = None
106104
_dynamo_to_python_attrs = None
107105

108106
@classmethod
@@ -137,7 +135,8 @@ def _get_attributes(cls):
137135
138136
:rtype: dict[str, Attribute]
139137
"""
140-
if cls._attributes is None:
138+
if '_attributes' not in cls.__dict__:
139+
# Each subclass of AttributeContainer needs its own attributes map.
141140
cls._initialize_attributes()
142141
return cls._attributes
143142

@@ -445,12 +444,6 @@ def deserialize(self, value):
445444
return None
446445

447446

448-
class MapAttributeMeta(type):
449-
def __init__(cls, name, bases, attrs):
450-
setattr(cls, '_attributes', None)
451-
452-
453-
@add_metaclass(MapAttributeMeta)
454447
class MapAttribute(AttributeContainer, Attribute):
455448
attr_type = MAP
456449

0 commit comments

Comments
 (0)