diff --git a/google/cloud/ndb/_datastore_types.py b/google/cloud/ndb/_datastore_types.py index faadb412..6d826f3e 100644 --- a/google/cloud/ndb/_datastore_types.py +++ b/google/cloud/ndb/_datastore_types.py @@ -51,8 +51,6 @@ class BlobKey(object): :class:`bytes` instance. """ - __slots__ = ("_blob_key",) - def __init__(self, blob_key): if isinstance(blob_key, bytes): if len(blob_key) > _MAX_STRING_LENGTH: diff --git a/google/cloud/ndb/_eventloop.py b/google/cloud/ndb/_eventloop.py index f50a6bca..7fffa361 100644 --- a/google/cloud/ndb/_eventloop.py +++ b/google/cloud/ndb/_eventloop.py @@ -135,15 +135,6 @@ class EventLoop(object): get added to this queue and then processed by the event loop. """ - __slots__ = ( - "current", - "idlers", - "inactive", - "queue", - "rpcs", - "rpc_results", - ) - def __init__(self): self.current = collections.deque() self.idlers = collections.deque() diff --git a/google/cloud/ndb/blobstore.py b/google/cloud/ndb/blobstore.py index ff1b616b..e2dc5028 100644 --- a/google/cloud/ndb/blobstore.py +++ b/google/cloud/ndb/blobstore.py @@ -78,8 +78,6 @@ def __init__(self, *args, **kwargs): class BlobInfo(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise exceptions.NoLongerImplementedError() @@ -111,8 +109,6 @@ def __init__(self, *args, **kwargs): class BlobReader(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise exceptions.NoLongerImplementedError() diff --git a/google/cloud/ndb/context.py b/google/cloud/ndb/context.py index 87f8c4c6..94cfe640 100644 --- a/google/cloud/ndb/context.py +++ b/google/cloud/ndb/context.py @@ -546,21 +546,15 @@ def urlfetch(self, *args, **kwargs): class ContextOptions(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise exceptions.NoLongerImplementedError() class TransactionOptions(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise exceptions.NoLongerImplementedError() class AutoBatcher(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise exceptions.NoLongerImplementedError() diff --git a/google/cloud/ndb/django_middleware.py b/google/cloud/ndb/django_middleware.py index 2bdfaf5b..dfb64210 100644 --- a/google/cloud/ndb/django_middleware.py +++ b/google/cloud/ndb/django_middleware.py @@ -19,7 +19,5 @@ class NdbDjangoMiddleware(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise NotImplementedError diff --git a/google/cloud/ndb/key.py b/google/cloud/ndb/key.py index 7ab96d54..5477c88c 100644 --- a/google/cloud/ndb/key.py +++ b/google/cloud/ndb/key.py @@ -272,8 +272,6 @@ class Key(object): arguments were given with the path. """ - __slots__ = ("_key", "_reference") - def __new__(cls, *path_args, **kwargs): # Avoid circular import in Python 2.7 from google.cloud.ndb import context as context_module diff --git a/google/cloud/ndb/metadata.py b/google/cloud/ndb/metadata.py index a58c5bbe..7099ed22 100644 --- a/google/cloud/ndb/metadata.py +++ b/google/cloud/ndb/metadata.py @@ -59,8 +59,6 @@ class _BaseMetadata(model.Model): """Base class for all metadata models.""" - __slots__ = () - _use_cache = False _use_global_cache = False @@ -81,8 +79,6 @@ def _get_kind(cls): class Namespace(_BaseMetadata): """Model for __namespace__ metadata query results.""" - __slots__ = () - KIND_NAME = "__namespace__" EMPTY_NAMESPACE_ID = 1 @@ -127,8 +123,6 @@ def key_to_namespace(cls, key): class Kind(_BaseMetadata): """Model for __kind__ metadata query results.""" - __slots__ = () - KIND_NAME = "__kind__" @property @@ -168,8 +162,6 @@ def key_to_kind(cls, key): class Property(_BaseMetadata): """Model for __property__ metadata query results.""" - __slots__ = () - KIND_NAME = "__property__" @property diff --git a/google/cloud/ndb/model.py b/google/cloud/ndb/model.py index cc5d9221..1942cff2 100644 --- a/google/cloud/ndb/model.py +++ b/google/cloud/ndb/model.py @@ -388,8 +388,6 @@ def __ne__(self, other): class IndexProperty(_NotEqualMixin): """Immutable object representing a single property in an index.""" - __slots__ = ("_name", "_direction") - @utils.positional(1) def __new__(cls, name, direction): instance = super(IndexProperty, cls).__new__(cls) @@ -426,8 +424,6 @@ def __hash__(self): class Index(_NotEqualMixin): """Immutable object representing an index.""" - __slots__ = ("_kind", "_properties", "_ancestor") - @utils.positional(1) def __new__(cls, kind, properties, ancestor): instance = super(Index, cls).__new__(cls) @@ -475,8 +471,6 @@ def __hash__(self): class IndexState(_NotEqualMixin): """Immutable object representing an index and its state.""" - __slots__ = ("_definition", "_state", "_id") - @utils.positional(1) def __new__(cls, definition, state, id): instance = super(IndexState, cls).__new__(cls) @@ -526,8 +520,6 @@ def __hash__(self): class ModelAdapter(object): - __slots__ = () - def __new__(self, *args, **kwargs): raise exceptions.NoLongerImplementedError() @@ -796,8 +788,6 @@ def make_connection(*args, **kwargs): class ModelAttribute(object): """Base for classes that implement a ``_fix_up()`` method.""" - __slots__ = () - def _fix_up(self, cls, code_name): """Fix-up property name. To be implemented by subclasses. @@ -824,8 +814,6 @@ class _BaseValue(_NotEqualMixin): TypeError: If ``b_val`` is a list. """ - __slots__ = ("b_val",) - def __init__(self, b_val): if b_val is None: raise TypeError("Cannot wrap None") @@ -2169,8 +2157,6 @@ class ModelKey(Property): .. automethod:: _validate """ - __slots__ = () - def __init__(self): super(ModelKey, self).__init__() self._name = "__key__" @@ -2253,8 +2239,6 @@ class BooleanProperty(Property): .. automethod:: _validate """ - __slots__ = () - def _validate(self, value): """Validate a ``value`` before setting it. @@ -2285,8 +2269,6 @@ class IntegerProperty(Property): .. automethod:: _validate """ - __slots__ = () - def _validate(self, value): """Validate a ``value`` before setting it. @@ -2318,8 +2300,6 @@ class FloatProperty(Property): .. automethod:: _validate """ - __slots__ = () - def _validate(self, value): """Validate a ``value`` before setting it. @@ -2602,8 +2582,6 @@ class Item(ndb.Model): NotImplementedError: If ``indexed=True`` is provided. """ - __slots__ = () - def __init__(self, *args, **kwargs): indexed = kwargs.pop("indexed", False) if indexed: @@ -2732,8 +2710,6 @@ class StringProperty(TextProperty): NotImplementedError: If ``indexed=False`` is provided. """ - __slots__ = () - def __init__(self, *args, **kwargs): indexed = kwargs.pop("indexed", True) if not indexed: @@ -2757,8 +2733,6 @@ class GeoPtProperty(Property): .. automethod:: _validate """ - __slots__ = () - def _validate(self, value): """Validate a ``value`` before setting it. @@ -2967,8 +2941,6 @@ class User(object): UserNotFoundError: If ``email`` is empty. """ - __slots__ = ("_auth_domain", "_email", "_user_id") - def __init__(self, email=None, _auth_domain=None, _user_id=None): if _auth_domain is None: raise ValueError("_auth_domain is required") @@ -3465,8 +3437,6 @@ class BlobKeyProperty(Property): .. automethod:: _validate """ - __slots__ = () - def _validate(self, value): """Validate a ``value`` before setting it. @@ -3685,8 +3655,6 @@ class DateProperty(DateTimeProperty): .. automethod:: _validate """ - __slots__ = () - def _validate(self, value): """Validate a ``value`` before setting it. @@ -3747,8 +3715,6 @@ class TimeProperty(DateTimeProperty): .. automethod:: _validate """ - __slots__ = () - def _validate(self, value): """Validate a ``value`` before setting it. diff --git a/google/cloud/ndb/msgprop.py b/google/cloud/ndb/msgprop.py index c693709f..201babe2 100644 --- a/google/cloud/ndb/msgprop.py +++ b/google/cloud/ndb/msgprop.py @@ -19,14 +19,10 @@ class EnumProperty(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise NotImplementedError class MessageProperty(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise NotImplementedError diff --git a/google/cloud/ndb/query.py b/google/cloud/ndb/query.py index 1bd21084..c889ca53 100644 --- a/google/cloud/ndb/query.py +++ b/google/cloud/ndb/query.py @@ -183,8 +183,6 @@ class PropertyOrder(object): or not (ascending). Default is False. """ - __slots__ = ["name", "reverse"] - def __init__(self, name, reverse=False): self.name = name self.reverse = reverse @@ -227,8 +225,6 @@ class RepeatedStructuredPropertyPredicate(object): contain a value for each key in ``match_keys``. """ - __slots__ = ["name", "match_keys", "match_values"] - def __init__(self, name, match_keys, entity_pb): self.name = name self.match_keys = match_keys @@ -305,8 +301,6 @@ class Parameter(ParameterizedThing): TypeError: If the ``key`` is not a string or integer. """ - __slots__ = ("_key",) - def __init__(self, key): if not isinstance(key, six.integer_types + six.string_types): raise TypeError( @@ -411,8 +405,6 @@ class Node(object): _multiquery = False - __slots__ = () - def __new__(cls): if cls is Node: raise TypeError("Cannot instantiate Node, only a subclass.") @@ -479,8 +471,6 @@ def resolve(self, bindings, used): class FalseNode(Node): """Tree node for an always-failing filter.""" - __slots__ = () - def __eq__(self, other): """Equality check. @@ -524,8 +514,6 @@ class ParameterNode(Node): :class:`.ParameterizedFunction`. """ - __slots__ = ("_prop", "_op", "_param") - def __new__(cls, prop, op, param): # Avoid circular import in Python 2.7 from google.cloud.ndb import model @@ -643,7 +631,9 @@ class FilterNode(Node): :class:`frozenset`) """ - __slots__ = ("_name", "_opsymbol", "_value") + _name = None + _opsymbol = None + _value = None def __new__(cls, name, opsymbol, value): # Avoid circular import in Python 2.7 @@ -754,8 +744,6 @@ class PostFilterNode(Node): the given filter. """ - __slots__ = ("predicate",) - def __new__(cls, predicate): instance = super(PostFilterNode, cls).__new__(cls) instance.predicate = predicate @@ -826,8 +814,6 @@ class _BooleanClauses(object): with the current boolean expression via ``AND`` or ``OR``. """ - __slots__ = ("name", "combine_or", "or_parts") - def __init__(self, name, combine_or): self.name = name self.combine_or = combine_or @@ -919,8 +905,6 @@ class ConjunctionNode(Node): expression. """ - __slots__ = ("_nodes",) - def __new__(cls, *nodes): if not nodes: raise TypeError("ConjunctionNode() requires at least one node.") @@ -1075,7 +1059,6 @@ class DisjunctionNode(Node): """ _multiquery = True - __slots__ = ("_nodes",) def __new__(cls, *nodes): if not nodes: diff --git a/google/cloud/ndb/stats.py b/google/cloud/ndb/stats.py index e60758a7..d1ba4c58 100644 --- a/google/cloud/ndb/stats.py +++ b/google/cloud/ndb/stats.py @@ -58,8 +58,6 @@ class BaseStatistic(model.Model): written to Cloud Datastore. """ - __slots__ = () - # This is necessary for the _get_kind() classmethod override. STORED_KIND_NAME = "__BaseStatistic__" @@ -85,8 +83,6 @@ class BaseKindStatistic(BaseStatistic): in Cloud Datastore minus the cost of storing indices. """ - __slots__ = () - STORED_KIND_NAME = "__BaseKindStatistic__" kind_name = model.StringProperty() @@ -112,8 +108,6 @@ class GlobalStat(BaseStatistic): composite_index_count (int): the number of composite index entries. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Total__" entity_bytes = model.IntegerProperty(default=0) @@ -148,8 +142,6 @@ class NamespaceStat(BaseStatistic): composite_index_count (int): the number of composite index entries. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Namespace__" subject_namespace = model.StringProperty() @@ -180,8 +172,6 @@ class KindStat(BaseKindStatistic): composite_index_count (int): the number of composite index entries. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Kind__" builtin_index_bytes = model.IntegerProperty(default=0) @@ -201,8 +191,6 @@ class KindRootEntityStat(BaseKindStatistic): stat contains statistics regarding these root entity instances. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Kind_IsRootEntity__" @@ -214,8 +202,6 @@ class KindNonRootEntityStat(BaseKindStatistic): contains statistics regarding these non root entity instances. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Kind_NotRootEntity__" @@ -236,8 +222,6 @@ class PropertyTypeStat(BaseStatistic): builtin_index_count (int): the number of built-in index entries. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_PropertyType__" property_type = model.StringProperty() @@ -263,8 +247,6 @@ class KindPropertyTypeStat(BaseKindStatistic): builtin_index_count (int): the number of built-in index entries. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_PropertyType_Kind__" property_type = model.StringProperty() @@ -288,8 +270,6 @@ class KindPropertyNameStat(BaseKindStatistic): builtin_index_count (int): the number of built-in index entries. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_PropertyName_Kind__" property_name = model.StringProperty() @@ -316,8 +296,6 @@ class KindPropertyNamePropertyTypeStat(BaseKindStatistic): builtin_index_count (int): the number of built-in index entries. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_PropertyType_PropertyName_Kind__" property_type = model.StringProperty() @@ -342,8 +320,6 @@ class KindCompositeIndexStat(BaseStatistic): instance. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Kind_CompositeIndex__" index_id = model.IntegerProperty() @@ -364,8 +340,6 @@ class NamespaceGlobalStat(GlobalStat): particular namespace. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Ns_Total__" @@ -376,8 +350,6 @@ class NamespaceKindStat(KindStat): particular namespace. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Ns_Kind__" @@ -388,8 +360,6 @@ class NamespaceKindRootEntityStat(KindRootEntityStat): particular namespace. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Ns_Kind_IsRootEntity__" @@ -400,8 +370,6 @@ class NamespaceKindNonRootEntityStat(KindNonRootEntityStat): particular namespace. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Ns_Kind_NotRootEntity__" @@ -412,8 +380,6 @@ class NamespacePropertyTypeStat(PropertyTypeStat): particular namespace. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Ns_PropertyType__" @@ -424,8 +390,6 @@ class NamespaceKindPropertyTypeStat(KindPropertyTypeStat): particular namespace. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Ns_PropertyType_Kind__" @@ -436,8 +400,6 @@ class NamespaceKindPropertyNameStat(KindPropertyNameStat): particular namespace. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Ns_PropertyName_Kind__" @@ -450,8 +412,6 @@ class NamespaceKindPropertyNamePropertyTypeStat( particular namespace. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Ns_PropertyType_PropertyName_Kind__" @@ -462,8 +422,6 @@ class NamespaceKindCompositeIndexStat(KindCompositeIndexStat): particular namespace. """ - __slots__ = () - STORED_KIND_NAME = "__Stat_Ns_Kind_CompositeIndex__" diff --git a/google/cloud/ndb/tasklets.py b/google/cloud/ndb/tasklets.py index bf34e28a..75ce8298 100644 --- a/google/cloud/ndb/tasklets.py +++ b/google/cloud/ndb/tasklets.py @@ -579,22 +579,16 @@ def make_default_context(*args, **kwargs): class QueueFuture(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise NotImplementedError class ReducingFuture(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise NotImplementedError class SerialQueueFuture(object): - __slots__ = () - def __init__(self, *args, **kwargs): raise NotImplementedError diff --git a/tests/system/test_misc.py b/tests/system/test_misc.py index eeb6d172..90c83b72 100644 --- a/tests/system/test_misc.py +++ b/tests/system/test_misc.py @@ -18,7 +18,6 @@ import pickle import pytest -import six from google.cloud import ndb @@ -40,9 +39,6 @@ def _get_kind(cls): return "SomeKind" -@pytest.mark.skipif( - six.PY2, reason="Pickling doesn't work in Python 2. See: Issue #311" -) @pytest.mark.usefixtures("client_context") def test_pickle_roundtrip_structured_property(dispose_of): """Regression test for Issue #281.