From e0c9518a93f57b9909c23d0a118ba2c1d5e336c1 Mon Sep 17 00:00:00 2001 From: jpinner-lyft Date: Mon, 10 Jun 2019 10:41:21 -0700 Subject: [PATCH] Remove MapAttributeMeta (#638) --- docs/release_notes.rst | 1 + pynamodb/attributes.py | 7 ------- pynamodb/attributes.pyi | 4 ++-- pynamodb/constants.pyi | 4 ---- pynamodb/tests/test_attributes.py | 7 +------ 5 files changed, 4 insertions(+), 19 deletions(-) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index f187f78b2..8005e5f15 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -48,6 +48,7 @@ Other changes in this release: * Added the ``max_pool_connection`` and ``extra_headers`` settings to replace common use cases for ``session_cls`` * Added support for `moto `_ through implementing the botocore "before-send" hook. Other botocore hooks remain unimplemented. * Performance improvements to ``UTCDateTimeAttribute`` deserialization. (#610) +* The ``MapAttributeMeta`` class has been removed. Now ``type(MapAttribute) == AttributeContainerMeta``. v3.3.3 diff --git a/pynamodb/attributes.py b/pynamodb/attributes.py index 3ee4aa025..b0970bc6e 100644 --- a/pynamodb/attributes.py +++ b/pynamodb/attributes.py @@ -565,13 +565,6 @@ def deserialize(self, value): return None -class MapAttributeMeta(AttributeContainerMeta): - """ - This is only here for backwards compatibility: i.e. so type(MapAttribute) == MapAttributeMeta - """ - - -@add_metaclass(MapAttributeMeta) class MapAttribute(Attribute, AttributeContainer): """ A Map Attribute diff --git a/pynamodb/attributes.pyi b/pynamodb/attributes.pyi index f2e522eb8..87fd66ec5 100644 --- a/pynamodb/attributes.pyi +++ b/pynamodb/attributes.pyi @@ -137,10 +137,10 @@ class NullAttribute(Attribute[None]): @overload def __get__(self, instance: Any, owner: Any) -> None: ... -class MapAttributeMeta(type): +class AttributeContainerMeta(type): def __init__(cls, name, bases, attrs) -> None: ... -class MapAttribute(Generic[_KT, _VT], Attribute[Mapping[_KT, _VT]], metaclass=MapAttributeMeta): +class MapAttribute(Generic[_KT, _VT], Attribute[Mapping[_KT, _VT]]): attribute_values: Any def __init__(self, hash_key: bool = ..., range_key: bool = ..., null: Optional[bool] = ..., default: Optional[Union[Any, Callable[..., Any]]] = ..., attr_name: Optional[Text] = ..., **attrs) -> None: ... def __iter__(self) -> Iterable[_VT]: ... diff --git a/pynamodb/constants.pyi b/pynamodb/constants.pyi index d078afcf9..4a3975f74 100644 --- a/pynamodb/constants.pyi +++ b/pynamodb/constants.pyi @@ -145,11 +145,7 @@ ALL_PROJECTED_ATTRIBUTES: str SPECIFIC_ATTRIBUTES: str COUNT: str SELECT_VALUES: List[str] -PAY_PER_REQUEST_BILLING_MODE: str -PROVISIONED_BILLING_MODE: str -AVAILABLE_BILLING_MODES: List[str] DEFAULT_BILLING_MODE: str -BILLING_MODE: str AND: str OR: str BETWEEN: str diff --git a/pynamodb/tests/test_attributes.py b/pynamodb/tests/test_attributes.py index 3651fa7d9..8223767c5 100644 --- a/pynamodb/tests/test_attributes.py +++ b/pynamodb/tests/test_attributes.py @@ -7,7 +7,6 @@ from base64 import b64encode from datetime import datetime -from dateutil.parser import parse from dateutil.tz import tzutc from mock import patch, Mock, call @@ -16,8 +15,7 @@ from pynamodb.attributes import ( BinarySetAttribute, BinaryAttribute, NumberSetAttribute, NumberAttribute, UnicodeAttribute, UnicodeSetAttribute, UTCDateTimeAttribute, BooleanAttribute, LegacyBooleanAttribute, - MapAttribute, MapAttributeMeta, ListAttribute, JSONAttribute, _get_value_for_deserialize, - _fast_parse_utc_datestring, + MapAttribute, ListAttribute, JSONAttribute, _get_value_for_deserialize, _fast_parse_utc_datestring, ) from pynamodb.constants import ( DATETIME_FORMAT, DEFAULT_ENCODING, NUMBER, STRING, STRING_SET, NUMBER_SET, BINARY_SET, @@ -828,9 +826,6 @@ class ThingModel(Model): with pytest.raises(KeyError): bad = t.nested['something_else'] - def test_metaclass(self): - assert type(MapAttribute) == MapAttributeMeta - def test_attribute_paths_subclassing(self): class SubMapAttribute(MapAttribute): foo = UnicodeAttribute(attr_name='dyn_foo')