From 3a70f34ddd8a74ded7cafb26b84f27382dd9d798 Mon Sep 17 00:00:00 2001 From: Roman Joost Date: Thu, 21 Oct 2021 15:15:53 +1000 Subject: [PATCH] Stubs for google.cloud.ndb the Google Cloud Datastore ndb client library (#5821) --- pyrightconfig.stricter.json | 1 + .../@tests/stubtest_allowlist.txt | 4 + stubs/google-cloud-ndb/METADATA.toml | 2 + stubs/google-cloud-ndb/google/__init__.pyi | 0 .../google/cloud/__init__.pyi | 0 .../google/cloud/ndb/__init__.pyi | 109 ++++ .../google/cloud/ndb/_batch.pyi | 3 + .../google/cloud/ndb/_cache.pyi | 72 +++ .../google/cloud/ndb/_datastore_api.pyi | 5 + .../google/cloud/ndb/_datastore_query.pyi | 22 + .../google/cloud/ndb/_eventloop.pyi | 26 + .../google/cloud/ndb/_options.pyi | 15 + .../google/cloud/ndb/_transaction.pyi | 18 + .../google/cloud/ndb/blobstore.pyi | 65 +++ .../google/cloud/ndb/client.pyi | 21 + .../google/cloud/ndb/context.pyi | 105 ++++ .../google/cloud/ndb/django_middleware.pyi | 2 + .../google/cloud/ndb/exceptions.pyi | 22 + .../google/cloud/ndb/global_cache.pyi | 75 +++ .../google-cloud-ndb/google/cloud/ndb/key.pyi | 98 ++++ .../google/cloud/ndb/metadata.pyi | 51 ++ .../google/cloud/ndb/model.pyi | 506 ++++++++++++++++++ .../google/cloud/ndb/msgprop.pyi | 5 + .../google/cloud/ndb/polymodel.pyi | 9 + .../google/cloud/ndb/query.pyi | 146 +++++ .../google/cloud/ndb/stats.pyi | 102 ++++ .../google/cloud/ndb/tasklets.pyi | 58 ++ .../google/cloud/ndb/utils.pyi | 28 + 28 files changed, 1570 insertions(+) create mode 100644 stubs/google-cloud-ndb/@tests/stubtest_allowlist.txt create mode 100644 stubs/google-cloud-ndb/METADATA.toml create mode 100644 stubs/google-cloud-ndb/google/__init__.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/__init__.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/__init__.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/_batch.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/_cache.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/_datastore_api.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/_datastore_query.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/_eventloop.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/_options.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/_transaction.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/blobstore.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/client.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/context.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/django_middleware.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/exceptions.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/global_cache.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/key.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/metadata.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/model.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/msgprop.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/polymodel.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/query.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/stats.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/tasklets.pyi create mode 100644 stubs/google-cloud-ndb/google/cloud/ndb/utils.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 0680f5ed5..aa71da99f 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -46,6 +46,7 @@ "stubs/paramiko", "stubs/prettytable", "stubs/protobuf", + "stubs/google-cloud-ndb", "stubs/psutil", "stubs/psycopg2", "stubs/Pygments", diff --git a/stubs/google-cloud-ndb/@tests/stubtest_allowlist.txt b/stubs/google-cloud-ndb/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000..a67cb1a30 --- /dev/null +++ b/stubs/google-cloud-ndb/@tests/stubtest_allowlist.txt @@ -0,0 +1,4 @@ +# inconsistency of signatures between stub and implementation (cls vs self) +google.cloud.ndb.ModelAdapter.__new__ +google.cloud.ndb.metadata.EntityGroup.__new__ +google.cloud.ndb.model.ModelAdapter.__new__ diff --git a/stubs/google-cloud-ndb/METADATA.toml b/stubs/google-cloud-ndb/METADATA.toml new file mode 100644 index 000000000..971cc4a0f --- /dev/null +++ b/stubs/google-cloud-ndb/METADATA.toml @@ -0,0 +1,2 @@ +version = "1.9.*" +requires = ["types-six"] diff --git a/stubs/google-cloud-ndb/google/__init__.pyi b/stubs/google-cloud-ndb/google/__init__.pyi new file mode 100644 index 000000000..e69de29bb diff --git a/stubs/google-cloud-ndb/google/cloud/__init__.pyi b/stubs/google-cloud-ndb/google/cloud/__init__.pyi new file mode 100644 index 000000000..e69de29bb diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/__init__.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/__init__.pyi new file mode 100644 index 000000000..3fb429e6e --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/__init__.pyi @@ -0,0 +1,109 @@ +from google.cloud.ndb._datastore_api import EVENTUAL as EVENTUAL, EVENTUAL_CONSISTENCY as EVENTUAL_CONSISTENCY, STRONG as STRONG +from google.cloud.ndb._datastore_query import Cursor as Cursor, QueryIterator as QueryIterator +from google.cloud.ndb._transaction import ( + in_transaction as in_transaction, + non_transactional as non_transactional, + transaction as transaction, + transaction_async as transaction_async, + transactional as transactional, + transactional_async as transactional_async, + transactional_tasklet as transactional_tasklet, +) +from google.cloud.ndb.client import Client as Client +from google.cloud.ndb.context import ( + AutoBatcher as AutoBatcher, + Context as Context, + ContextOptions as ContextOptions, + TransactionOptions as TransactionOptions, + get_context as get_context, + get_toplevel_context as get_toplevel_context, +) +from google.cloud.ndb.global_cache import GlobalCache as GlobalCache, MemcacheCache as MemcacheCache, RedisCache as RedisCache +from google.cloud.ndb.key import Key as Key +from google.cloud.ndb.model import ( + BadProjectionError as BadProjectionError, + BlobKey as BlobKey, + BlobKeyProperty as BlobKeyProperty, + BlobProperty as BlobProperty, + BooleanProperty as BooleanProperty, + ComputedProperty as ComputedProperty, + ComputedPropertyError as ComputedPropertyError, + DateProperty as DateProperty, + DateTimeProperty as DateTimeProperty, + Expando as Expando, + FloatProperty as FloatProperty, + GenericProperty as GenericProperty, + GeoPt as GeoPt, + GeoPtProperty as GeoPtProperty, + Index as Index, + IndexProperty as IndexProperty, + IndexState as IndexState, + IntegerProperty as IntegerProperty, + InvalidPropertyError as InvalidPropertyError, + JsonProperty as JsonProperty, + KeyProperty as KeyProperty, + KindError as KindError, + LocalStructuredProperty as LocalStructuredProperty, + MetaModel as MetaModel, + Model as Model, + ModelAdapter as ModelAdapter, + ModelAttribute as ModelAttribute, + ModelKey as ModelKey, + PickleProperty as PickleProperty, + Property as Property, + ReadonlyPropertyError as ReadonlyPropertyError, + Rollback as Rollback, + StringProperty as StringProperty, + StructuredProperty as StructuredProperty, + TextProperty as TextProperty, + TimeProperty as TimeProperty, + UnprojectedPropertyError as UnprojectedPropertyError, + User as User, + UserNotFoundError as UserNotFoundError, + UserProperty as UserProperty, + delete_multi as delete_multi, + delete_multi_async as delete_multi_async, + get_indexes as get_indexes, + get_indexes_async as get_indexes_async, + get_multi as get_multi, + get_multi_async as get_multi_async, + make_connection as make_connection, + put_multi as put_multi, + put_multi_async as put_multi_async, +) +from google.cloud.ndb.polymodel import PolyModel as PolyModel +from google.cloud.ndb.query import ( + AND as AND, + OR as OR, + ConjunctionNode as ConjunctionNode, + DisjunctionNode as DisjunctionNode, + FalseNode as FalseNode, + FilterNode as FilterNode, + Node as Node, + Parameter as Parameter, + ParameterizedFunction as ParameterizedFunction, + ParameterizedThing as ParameterizedThing, + ParameterNode as ParameterNode, + PostFilterNode as PostFilterNode, + Query as Query, + QueryOptions as QueryOptions, + RepeatedStructuredPropertyPredicate as RepeatedStructuredPropertyPredicate, + gql as gql, +) +from google.cloud.ndb.tasklets import ( + Future as Future, + QueueFuture as QueueFuture, + ReducingFuture as ReducingFuture, + Return as Return, + SerialQueueFuture as SerialQueueFuture, + add_flow_exception as add_flow_exception, + make_context as make_context, + make_default_context as make_default_context, + set_context as set_context, + sleep as sleep, + synctasklet as synctasklet, + tasklet as tasklet, + toplevel as toplevel, + wait_all as wait_all, + wait_any as wait_any, +) diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/_batch.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/_batch.pyi new file mode 100644 index 000000000..0f50383e9 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/_batch.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def get_batch(batch_cls, options: Any | None = ...): ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/_cache.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/_cache.pyi new file mode 100644 index 000000000..dd86c584e --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/_cache.pyi @@ -0,0 +1,72 @@ +from typing import Any + +from google.cloud.ndb import tasklets as tasklets + +class ContextCache: + def get_and_validate(self, key): ... + +class _GlobalCacheBatch: + def full(self): ... + def idle_callback(self) -> None: ... + def done_callback(self, cache_call) -> None: ... + def make_call(self) -> None: ... + def future_info(self, key) -> None: ... + +global_get: Any + +class _GlobalCacheGetBatch(_GlobalCacheBatch): + todo: Any + keys: Any + def __init__(self, ignore_options) -> None: ... + def add(self, key): ... + def done_callback(self, cache_call) -> None: ... + def make_call(self): ... + def future_info(self, key): ... + +def global_set(key, value, expires: Any | None = ..., read: bool = ...): ... + +class _GlobalCacheSetBatch(_GlobalCacheBatch): + expires: Any + todo: object + futures: object + def __init__(self, options) -> None: ... + def done_callback(self, cache_call) -> None: ... + def add(self, key, value): ... + def make_call(self): ... + def future_info(self, key, value): ... + +class _GlobalCacheSetIfNotExistsBatch(_GlobalCacheSetBatch): + def add(self, key, value): ... + def make_call(self): ... + def future_info(self, key, value): ... + +global_delete: Any + +class _GlobalCacheDeleteBatch(_GlobalCacheBatch): + keys: Any + futures: Any + def __init__(self, ignore_options) -> None: ... + def add(self, key): ... + def make_call(self): ... + def future_info(self, key): ... + +global_watch: Any + +class _GlobalCacheWatchBatch(_GlobalCacheDeleteBatch): + def make_call(self): ... + def future_info(self, key): ... + +def global_unwatch(key): ... + +class _GlobalCacheUnwatchBatch(_GlobalCacheDeleteBatch): + def make_call(self): ... + def future_info(self, key): ... + +global_compare_and_swap: Any + +class _GlobalCacheCompareAndSwapBatch(_GlobalCacheSetBatch): + def make_call(self): ... + def future_info(self, key, value): ... + +def is_locked_value(value): ... +def global_cache_key(key): ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/_datastore_api.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/_datastore_api.pyi new file mode 100644 index 000000000..67b9641d6 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/_datastore_api.pyi @@ -0,0 +1,5 @@ +from typing_extensions import Literal + +EVENTUAL: Literal[2] +EVENTUAL_CONSISTENCY: Literal[2] +STRONG: Literal[1] diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/_datastore_query.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/_datastore_query.pyi new file mode 100644 index 000000000..c199db496 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/_datastore_query.pyi @@ -0,0 +1,22 @@ +from typing import Any + +class QueryIterator: + def __iter__(self): ... + def has_next(self) -> None: ... + def has_next_async(self) -> None: ... + def probably_has_next(self) -> None: ... + def next(self) -> None: ... + def cursor_before(self) -> None: ... + def cursor_after(self) -> None: ... + def index_list(self) -> None: ... + +class Cursor: + @classmethod + def from_websafe_string(cls, urlsafe): ... + cursor: Any + def __init__(self, cursor: Any | None = ..., urlsafe: Any | None = ...) -> None: ... + def to_websafe_string(self): ... + def urlsafe(self): ... + def __eq__(self, other): ... + def __ne__(self, other): ... + def __hash__(self): ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/_eventloop.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/_eventloop.pyi new file mode 100644 index 000000000..2c80cd375 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/_eventloop.pyi @@ -0,0 +1,26 @@ +from typing import Any, NamedTuple + +class _Event(NamedTuple): + when: Any + callback: Any + args: Any + kwargs: Any + +class EventLoop: + current: Any + idlers: Any + inactive: int + queue: Any + rpcs: Any + rpc_results: Any + def __init__(self) -> None: ... + def clear(self) -> None: ... + def insort_event_right(self, event) -> None: ... + def call_soon(self, callback, *args, **kwargs) -> None: ... + def queue_call(self, delay, callback, *args, **kwargs) -> None: ... + def queue_rpc(self, rpc, callback) -> None: ... + def add_idle(self, callback, *args, **kwargs) -> None: ... + def run_idle(self): ... + def run0(self): ... + def run1(self): ... + def run(self) -> None: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/_options.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/_options.pyi new file mode 100644 index 000000000..153e041a5 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/_options.pyi @@ -0,0 +1,15 @@ +from typing import Any + +class Options: + @classmethod + def options(cls, wrapped): ... + @classmethod + def slots(cls): ... + def __init__(self, config: Any | None = ..., **kwargs) -> None: ... + def __eq__(self, other): ... + def __ne__(self, other): ... + def copy(self, **kwargs): ... + def items(self) -> None: ... + +class ReadOptions(Options): + def __init__(self, config: Any | None = ..., **kwargs) -> None: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/_transaction.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/_transaction.pyi new file mode 100644 index 000000000..c3dc5a473 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/_transaction.pyi @@ -0,0 +1,18 @@ +from typing import Any + +def in_transaction(): ... +def transaction( + callback, retries=..., read_only: bool = ..., join: bool = ..., xg: bool = ..., propagation: Any | None = ... +): ... +def transaction_async( + callback, retries=..., read_only: bool = ..., join: bool = ..., xg: bool = ..., propagation: Any | None = ... +): ... +def transaction_async_( + callback, retries=..., read_only: bool = ..., join: bool = ..., xg: bool = ..., propagation: Any | None = ... +): ... +def transactional(retries=..., read_only: bool = ..., join: bool = ..., xg: bool = ..., propagation: Any | None = ...): ... +def transactional_async(retries=..., read_only: bool = ..., join: bool = ..., xg: bool = ..., propagation: Any | None = ...): ... +def transactional_tasklet( + retries=..., read_only: bool = ..., join: bool = ..., xg: bool = ..., propagation: Any | None = ... +): ... +def non_transactional(allow_existing: bool = ...): ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/blobstore.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/blobstore.pyi new file mode 100644 index 000000000..acb002aad --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/blobstore.pyi @@ -0,0 +1,65 @@ +from typing import Any + +from google.cloud.ndb import model + +BlobKey: Any +BLOB_INFO_KIND: str +BLOB_MIGRATION_KIND: str +BLOB_KEY_HEADER: str +BLOB_RANGE_HEADER: str +MAX_BLOB_FETCH_SIZE: int +UPLOAD_INFO_CREATION_HEADER: str +BlobKeyProperty = model.BlobKeyProperty + +class BlobFetchSizeTooLargeError: + def __init__(self, *args, **kwargs) -> None: ... + +class BlobInfo: + def __init__(self, *args, **kwargs) -> None: ... + @classmethod + def get(cls, *args, **kwargs) -> None: ... + @classmethod + def get_async(cls, *args, **kwargs) -> None: ... + @classmethod + def get_multi(cls, *args, **kwargs) -> None: ... + @classmethod + def get_multi_async(cls, *args, **kwargs) -> None: ... + +class BlobInfoParseError: + def __init__(self, *args, **kwargs) -> None: ... + +class BlobNotFoundError: + def __init__(self, *args, **kwargs) -> None: ... + +class BlobReader: + def __init__(self, *args, **kwargs) -> None: ... + +def create_upload_url(*args, **kwargs) -> None: ... +def create_upload_url_async(*args, **kwargs) -> None: ... + +class DataIndexOutOfRangeError: + def __init__(self, *args, **kwargs) -> None: ... + +def delete(*args, **kwargs) -> None: ... +def delete_async(*args, **kwargs) -> None: ... +def delete_multi(*args, **kwargs) -> None: ... +def delete_multi_async(*args, **kwargs) -> None: ... + +class Error: + def __init__(self, *args, **kwargs) -> None: ... + +def fetch_data(*args, **kwargs) -> None: ... +def fetch_data_async(*args, **kwargs) -> None: ... + +get: Any +get_async: Any +get_multi: Any +get_multi_async: Any + +class InternalError: + def __init__(self, *args, **kwargs) -> None: ... + +def parse_blob_info(*args, **kwargs) -> None: ... + +class PermissionDeniedError: + def __init__(self, *args, **kwargs) -> None: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/client.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/client.pyi new file mode 100644 index 000000000..207673ea1 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/client.pyi @@ -0,0 +1,21 @@ +from typing import Any + +DATASTORE_API_HOST: Any + +class Client: + SCOPE: Any + namespace: Any + host: Any + client_info: Any + secure: Any + stub: Any + def __init__(self, project: Any | None = ..., namespace: Any | None = ..., credentials: Any | None = ...) -> None: ... + def context( + self, + namespace=..., + cache_policy: Any | None = ..., + global_cache: Any | None = ..., + global_cache_policy: Any | None = ..., + global_cache_timeout_policy: Any | None = ..., + legacy_data: bool = ..., + ) -> None: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/context.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/context.pyi new file mode 100644 index 000000000..bb3538fab --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/context.pyi @@ -0,0 +1,105 @@ +from typing import Any, Callable, NamedTuple + +from google.cloud.ndb import Key, exceptions as exceptions + +class _LocalState: + def __init__(self) -> None: ... + @property + def context(self): ... + @context.setter + def context(self, value) -> None: ... + @property + def toplevel_context(self): ... + @toplevel_context.setter + def toplevel_context(self, value) -> None: ... + +def get_context(raise_context_error: bool = ...): ... +def get_toplevel_context(raise_context_error: bool = ...): ... + +class _ContextTuple(NamedTuple): + client: Any + namespace: Any + eventloop: Any + batches: Any + commit_batches: Any + transaction: Any + cache: Any + global_cache: Any + on_commit_callbacks: Any + legacy_data: Any + +class _Context(_ContextTuple): + def __new__( + cls, + client, + namespace=..., + eventloop: Any | None = ..., + batches: Any | None = ..., + commit_batches: Any | None = ..., + transaction: Any | None = ..., + cache: Any | None = ..., + cache_policy: Any | None = ..., + global_cache: Any | None = ..., + global_cache_flush_keys: object | None = ..., + global_cache_policy: Callable[[Key], bool] | None = ..., + global_cache_timeout_policy: Any | None = ..., + datastore_policy: Any | None = ..., + on_commit_callbacks: Any | None = ..., + legacy_data: bool = ..., + retry: Any | None = ..., + rpc_time: Any | None = ..., + wait_time: Any | None = ..., + ): ... + def new(self, **kwargs): ... + rpc_time: int + wait_time: int + def use(self) -> None: ... + +class Context(_Context): + def clear_cache(self) -> None: ... + def flush(self) -> None: ... + def get_namespace(self): ... + def get_cache_policy(self): ... + def get_datastore_policy(self) -> None: ... + def get_global_cache_policy(self): ... + get_memcache_policy: Any + def get_global_cache_timeout_policy(self): ... + get_memcache_timeout_policy: Any + cache_policy: Any + def set_cache_policy(self, policy): ... + datastore_policy: Any + def set_datastore_policy(self, policy): ... + global_cache_policy: Any + def set_global_cache_policy(self, policy): ... + set_memcache_policy: Any + global_cache_timeout_policy: Any + def set_global_cache_timeout_policy(self, policy): ... + set_memcache_timeout_policy: Any + def get_retry_state(self): ... + def set_retry_state(self, state) -> None: ... + def clear_retry_state(self) -> None: ... + def call_on_commit(self, callback) -> None: ... + def in_transaction(self): ... + def in_retry(self): ... + def memcache_add(self, *args, **kwargs) -> None: ... + def memcache_cas(self, *args, **kwargs) -> None: ... + def memcache_decr(self, *args, **kwargs) -> None: ... + def memcache_delete(self, *args, **kwargs) -> None: ... + def memcache_get(self, *args, **kwargs) -> None: ... + def memcache_gets(self, *args, **kwargs) -> None: ... + def memcache_incr(self, *args, **kwargs) -> None: ... + def memcache_replace(self, *args, **kwargs) -> None: ... + def memcache_set(self, *args, **kwargs) -> None: ... + def urlfetch(self, *args, **kwargs) -> None: ... + +class ContextOptions: + def __init__(self, *args, **kwargs) -> None: ... + +class TransactionOptions: + NESTED: int + MANDATORY: int + ALLOWED: int + INDEPENDENT: int + +class AutoBatcher: + def __init__(self, *args, **kwargs) -> None: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/django_middleware.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/django_middleware.pyi new file mode 100644 index 000000000..8d4c846e5 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/django_middleware.pyi @@ -0,0 +1,2 @@ +class NdbDjangoMiddleware: + def __init__(self, *args, **kwargs) -> None: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/exceptions.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/exceptions.pyi new file mode 100644 index 000000000..ab5a3a0ae --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/exceptions.pyi @@ -0,0 +1,22 @@ +from typing import Any + +class Error(Exception): ... + +class ContextError(Error): + def __init__(self) -> None: ... + +class BadValueError(Error): ... +class BadArgumentError(Error): ... +class BadRequestError(Error): ... +class Rollback(Error): ... +class BadQueryError(Error): ... + +class BadFilterError(Error): + filter: Any + def __init__(self, filter) -> None: ... + +class NoLongerImplementedError(NotImplementedError): + def __init__(self) -> None: ... + +class Cancelled(Error): ... +class NestedRetryException(Error): ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/global_cache.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/global_cache.pyi new file mode 100644 index 000000000..bcc4aa155 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/global_cache.pyi @@ -0,0 +1,75 @@ +import abc +from typing import Any + +ConnectionError: Any + +class GlobalCache(metaclass=abc.ABCMeta): + __metaclass__: Any + transient_errors: Any + strict_read: bool + strict_write: bool + @abc.abstractmethod + def get(self, keys): ... + @abc.abstractmethod + def set(self, items, expires: Any | None = ...): ... + @abc.abstractmethod + def delete(self, keys): ... + @abc.abstractmethod + def watch(self, keys): ... + @abc.abstractmethod + def unwatch(self, keys): ... + @abc.abstractmethod + def compare_and_swap(self, items, expires: Any | None = ...): ... + @abc.abstractmethod + def clear(self): ... + +class _InProcessGlobalCache(GlobalCache): + cache: Any + def __init__(self) -> None: ... + def get(self, keys): ... + def set(self, items, expires: Any | None = ...) -> None: ... + def delete(self, keys) -> None: ... + def watch(self, keys) -> None: ... + def unwatch(self, keys) -> None: ... + def compare_and_swap(self, items, expires: Any | None = ...): ... + def clear(self) -> None: ... + +class RedisCache(GlobalCache): + transient_errors: Any + @classmethod + def from_environment(cls, strict_read: bool = ..., strict_write: bool = ...): ... + redis: Any + strict_read: Any + strict_write: Any + def __init__(self, redis, strict_read: bool = ..., strict_write: bool = ...) -> None: ... + @property + def pipes(self): ... + def get(self, keys): ... + def set(self, items, expires: Any | None = ...) -> None: ... + def delete(self, keys) -> None: ... + def watch(self, keys) -> None: ... + def unwatch(self, keys) -> None: ... + def compare_and_swap(self, items, expires: Any | None = ...): ... + def clear(self) -> None: ... + +class MemcacheCache(GlobalCache): + class KeyNotSet(Exception): + key: Any + def __init__(self, key) -> None: ... + def __eq__(self, other): ... + transient_errors: Any + @classmethod + def from_environment(cls, max_pool_size: int = ..., strict_read: bool = ..., strict_write: bool = ...): ... + client: Any + strict_read: Any + strict_write: Any + def __init__(self, client, strict_read: bool = ..., strict_write: bool = ...) -> None: ... + @property + def caskeys(self): ... + def get(self, keys): ... + def set(self, items, expires: Any | None = ...): ... + def delete(self, keys) -> None: ... + def watch(self, keys) -> None: ... + def unwatch(self, keys) -> None: ... + def compare_and_swap(self, items, expires: Any | None = ...): ... + def clear(self) -> None: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/key.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/key.pyi new file mode 100644 index 000000000..6a9896e3d --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/key.pyi @@ -0,0 +1,98 @@ +from typing import Any + +UNDEFINED: Any + +class Key: + def __new__(cls, *path_args, **kwargs): ... + def __hash__(self): ... + def __eq__(self, other): ... + def __ne__(self, other): ... + def __lt__(self, other): ... + def __le__(self, other): ... + def __gt__(self, other): ... + def __ge__(self, other): ... + def __getnewargs__(self): ... + def parent(self): ... + def root(self): ... + def namespace(self): ... + def project(self): ... + app: Any + def id(self): ... + def string_id(self): ... + def integer_id(self): ... + def pairs(self): ... + def flat(self): ... + def kind(self): ... + def reference(self): ... + def serialized(self): ... + def urlsafe(self): ... + def to_legacy_urlsafe(self, location_prefix): ... + def get( + self, + read_consistency: Any | None = ..., + read_policy: Any | None = ..., + transaction: Any | None = ..., + retries: Any | None = ..., + timeout: Any | None = ..., + deadline: Any | None = ..., + use_cache: Any | None = ..., + use_global_cache: Any | None = ..., + use_datastore: Any | None = ..., + global_cache_timeout: Any | None = ..., + use_memcache: Any | None = ..., + memcache_timeout: Any | None = ..., + max_memcache_items: Any | None = ..., + force_writes: Any | None = ..., + _options: Any | None = ..., + ): ... + def get_async( + self, + read_consistency: Any | None = ..., + read_policy: Any | None = ..., + transaction: Any | None = ..., + retries: Any | None = ..., + timeout: Any | None = ..., + deadline: Any | None = ..., + use_cache: Any | None = ..., + use_global_cache: Any | None = ..., + use_datastore: Any | None = ..., + global_cache_timeout: Any | None = ..., + use_memcache: Any | None = ..., + memcache_timeout: Any | None = ..., + max_memcache_items: Any | None = ..., + force_writes: Any | None = ..., + _options: Any | None = ..., + ): ... + def delete( + self, + retries: Any | None = ..., + timeout: Any | None = ..., + deadline: Any | None = ..., + use_cache: Any | None = ..., + use_global_cache: Any | None = ..., + use_datastore: Any | None = ..., + global_cache_timeout: Any | None = ..., + use_memcache: Any | None = ..., + memcache_timeout: Any | None = ..., + max_memcache_items: Any | None = ..., + force_writes: Any | None = ..., + _options: Any | None = ..., + ): ... + def delete_async( + self, + retries: Any | None = ..., + timeout: Any | None = ..., + deadline: Any | None = ..., + use_cache: Any | None = ..., + use_global_cache: Any | None = ..., + use_datastore: Any | None = ..., + global_cache_timeout: Any | None = ..., + use_memcache: Any | None = ..., + memcache_timeout: Any | None = ..., + max_memcache_items: Any | None = ..., + force_writes: Any | None = ..., + _options: Any | None = ..., + ): ... + @classmethod + def from_old_key(cls, old_key) -> None: ... + def to_old_key(self) -> None: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/metadata.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/metadata.pyi new file mode 100644 index 000000000..6c8d33924 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/metadata.pyi @@ -0,0 +1,51 @@ +from typing import Any + +from google.cloud.ndb import model + +class _BaseMetadata(model.Model): + KIND_NAME: str + def __new__(cls, *args, **kwargs): ... + +class Namespace(_BaseMetadata): + KIND_NAME: str + EMPTY_NAMESPACE_ID: int + @property + def namespace_name(self): ... + @classmethod + def key_for_namespace(cls, namespace): ... + @classmethod + def key_to_namespace(cls, key): ... + +class Kind(_BaseMetadata): + KIND_NAME: str + @property + def kind_name(self): ... + @classmethod + def key_for_kind(cls, kind): ... + @classmethod + def key_to_kind(cls, key): ... + +class Property(_BaseMetadata): + KIND_NAME: str + @property + def property_name(self): ... + @property + def kind_name(self): ... + property_representation: Any + @classmethod + def key_for_kind(cls, kind): ... + @classmethod + def key_for_property(cls, kind, property): ... + @classmethod + def key_to_kind(cls, key): ... + @classmethod + def key_to_property(cls, key): ... + +class EntityGroup: + def __new__(cls, *args, **kwargs): ... + +def get_entity_group_version(*args, **kwargs) -> None: ... +def get_kinds(start: Any | None = ..., end: Any | None = ...): ... +def get_namespaces(start: Any | None = ..., end: Any | None = ...): ... +def get_properties_of_kind(kind, start: Any | None = ..., end: Any | None = ...): ... +def get_representations_of_kind(kind, start: Any | None = ..., end: Any | None = ...): ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi new file mode 100644 index 000000000..08d663f96 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi @@ -0,0 +1,506 @@ +import datetime +from collections.abc import Iterable, Sequence +from typing import Callable, NoReturn, Type +from typing_extensions import Literal + +from google.cloud.ndb import exceptions, key as key_module, query as query_module, tasklets as tasklets_module + +Key = key_module.Key +Rollback = exceptions.Rollback +BlobKey: object +GeoPt: object + +class KindError(exceptions.BadValueError): ... +class InvalidPropertyError(exceptions.Error): ... + +BadProjectionError = InvalidPropertyError + +class UnprojectedPropertyError(exceptions.Error): ... +class ReadonlyPropertyError(exceptions.Error): ... +class ComputedPropertyError(ReadonlyPropertyError): ... +class UserNotFoundError(exceptions.Error): ... + +class _NotEqualMixin: + def __ne__(self, other: object) -> bool: ... + +DirectionT = Literal["asc", "desc"] + +class IndexProperty(_NotEqualMixin): + def __new__(cls, name: str, direction: DirectionT) -> IndexProperty: ... + @property + def name(self) -> str: ... + @property + def direction(self) -> DirectionT: ... + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... + +class Index(_NotEqualMixin): + def __new__(cls, kind: str, properties: list[IndexProperty], ancestor: bool) -> Index: ... + @property + def kind(self) -> str: ... + @property + def properties(self) -> list[IndexProperty]: ... + @property + def ancestor(self) -> bool: ... + def __eq__(self, other) -> bool: ... + def __hash__(self) -> int: ... + +class IndexState(_NotEqualMixin): + def __new__(cls, definition, state, id): ... + @property + def definition(self): ... + @property + def state(self): ... + @property + def id(self): ... + def __eq__(self, other) -> bool: ... + def __hash__(self) -> int: ... + +class ModelAdapter: + def __new__(cls, *args, **kwargs) -> ModelAdapter: ... + +def make_connection(*args, **kwargs) -> NoReturn: ... + +class ModelAttribute: ... + +class _BaseValue(_NotEqualMixin): + b_val: object = ... + def __init__(self, b_val) -> None: ... + def __eq__(self, other) -> bool: ... + def __hash__(self) -> int: ... + +class Property(ModelAttribute): + def __init__( + self, + name: str | None = ..., + indexed: bool | None = ..., + repeated: bool | None = ..., + required: bool | None = ..., + default: object | None = ..., + choices: Iterable[object] | None = ..., + validator: Callable[[Property], object] | None = ..., + verbose_name: str | None = ..., + write_empty_list: bool | None = ..., + ) -> None: ... + def __eq__(self, value: object) -> query_module.FilterNode: ... # type: ignore[override] + def __ne__(self, value: object) -> query_module.FilterNode: ... # type: ignore[override] + def __lt__(self, value: object) -> query_module.FilterNode: ... + def __le__(self, value: object) -> query_module.FilterNode: ... + def __gt__(self, value: object) -> query_module.FilterNode: ... + def __ge__(self, value: object) -> query_module.FilterNode: ... + def IN(self, value: Iterable[object]) -> query_module.DisjunctionNode | query_module.FilterNode | query_module.FalseNode: ... + def __neg__(self) -> query_module.PropertyOrder: ... + def __pos__(self) -> query_module.PropertyOrder: ... + def __set__(self, entity: Model, value: object) -> None: ... + def __delete__(self, entity: Model) -> None: ... + +class ModelKey(Property): + def __init__(self) -> None: ... + def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> key_module.Key | list[key_module.Key] | None: ... + +class BooleanProperty(Property): + def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> bool | list[bool] | None: ... + +class IntegerProperty(Property): + def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> int | list[int] | None: ... + +class FloatProperty(Property): + def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> float | list[float] | None: ... + +class _CompressedValue(bytes): + z_val: bytes = ... + def __init__(self, z_val: bytes) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> NoReturn: ... + +class BlobProperty(Property): + def __init__( + self, + name: str | None = ..., + compressed: bool | None = ..., + indexed: bool | None = ..., + repeated: bool | None = ..., + required: bool | None = ..., + default: bytes | None = ..., + choices: Iterable[bytes] | None = ..., + validator: Callable[[Property], object] | None = ..., + verbose_name: str | None = ..., + write_empty_list: bool | None = ..., + ) -> None: ... + def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> bytes | list[bytes] | None: ... + +class CompressedTextProperty(BlobProperty): + def __init__(self, *args, **kwargs) -> None: ... + +class TextProperty(Property): + def __new__(cls, *args, **kwargs): ... + def __init__(self, *args, **kwargs) -> None: ... + def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> str | list[str] | None: ... + +class StringProperty(TextProperty): + def __init__(self, *args, **kwargs) -> None: ... + +class GeoPtProperty(Property): ... +class PickleProperty(BlobProperty): ... + +class JsonProperty(BlobProperty): + def __init__( + self, + name: str | None = ..., + compressed: bool | None = ..., + json_type: type | None = ..., + indexed: bool | None = ..., + repeated: bool | None = ..., + required: bool | None = ..., + default: object | None = ..., + choices: Iterable[object] | None = ..., + validator: Callable[[Property], object] | None = ..., + verbose_name: str | None = ..., + write_empty_list: bool | None = ..., + ) -> None: ... + +class User: + def __init__(self, email: str | None = ..., _auth_domain: str | None = ..., _user_id: str | None = ...) -> None: ... + def nickname(self) -> str: ... + def email(self): ... + def user_id(self) -> str | None: ... + def auth_domain(self) -> str: ... + def __hash__(self) -> int: ... + def __eq__(self, other: object) -> bool: ... + def __lt__(self, other: object) -> bool: ... + +class UserProperty(Property): + def __init__( + self, + name: str | None = ..., + auto_current_user: bool | None = ..., + auto_current_user_add: bool | None = ..., + indexed: bool | None = ..., + repeated: bool | None = ..., + required: bool | None = ..., + default: bytes | None = ..., + choices: Iterable[bytes] | None = ..., + validator: Callable[[Property], object] | None = ..., + verbose_name: str | None = ..., + write_empty_list: bool | None = ..., + ) -> None: ... + +class KeyProperty(Property): + def __init__( + self, + name: str | None = ..., + kind: Type[Model] | str | None = ..., + indexed: bool | None = ..., + repeated: bool | None = ..., + required: bool | None = ..., + default: key_module.Key | None = ..., + choices: Iterable[key_module.Key] | None = ..., + validator: Callable[[Property, key_module.Key], bool] | None = ..., + verbose_name: str | None = ..., + write_empty_list: bool | None = ..., + ) -> None: ... + +class BlobKeyProperty(Property): ... + +class DateTimeProperty(Property): + def __init__( + self, + name: str | None = ..., + auto_now: bool | None = ..., + auto_now_add: bool | None = ..., + tzinfo: datetime.tzinfo | None = ..., + indexed: bool | None = ..., + repeated: bool | None = ..., + required: bool | None = ..., + default: datetime.datetime | None = ..., + choices: Iterable[datetime.datetime] | None = ..., + validator: Callable[[Property, object], bool] | None = ..., + verbose_name: str | None = ..., + write_empty_list: bool | None = ..., + ) -> None: ... + +class DateProperty(DateTimeProperty): ... +class TimeProperty(DateTimeProperty): ... + +class StructuredProperty(Property): + def __init__(self, model_class: type, name: str | None = ..., **kwargs) -> None: ... + def __getattr__(self, attrname): ... + def IN(self, value: Iterable[object]) -> query_module.DisjunctionNode | query_module.FalseNode: ... + +class LocalStructuredProperty(BlobProperty): + def __init__(self, model_class: Type[Model], **kwargs) -> None: ... + +class GenericProperty(Property): + def __init__(self, name: str | None = ..., compressed: bool = ..., **kwargs) -> None: ... + +class ComputedProperty(GenericProperty): + def __init__( + self, + func: Callable[[Model], object], + name: str | None = ..., + indexed: bool | None = ..., + repeated: bool | None = ..., + verbose_name: str | None = ..., + ) -> None: ... + +class MetaModel(type): + def __init__(cls, name: str, bases, classdict) -> None: ... + +class Model(_NotEqualMixin, metaclass=MetaModel): + key: ModelKey = ... + def __init__(_self, **kwargs) -> None: ... + def __hash__(self) -> NoReturn: ... + def __eq__(self, other: object) -> bool: ... + @classmethod + def gql(cls: Type[Model], query_string: str, *args, **kwargs) -> query_module.Query: ... + def put(self, **kwargs): ... + def put_async(self, **kwargs) -> tasklets_module.Future: ... + @classmethod + def query(cls: Type[Model], *args, **kwargs) -> query_module.Query: ... + @classmethod + def allocate_ids( + cls: Type[Model], + size: int | None = ..., + max: int | None = ..., + parent: key_module.Key | None = ..., + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options=..., + ) -> tuple[key_module.Key, key_module.Key]: ... + @classmethod + def allocate_ids_async( + cls: Type[Model], + size: int | None = ..., + max: int | None = ..., + parent: key_module.Key | None = ..., + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options=..., + ) -> tasklets_module.Future: ... + @classmethod + def get_by_id( + cls: Type[Model], + id: int | str | None, + parent: key_module.Key | None = ..., + namespace: str | None = ..., + project: str | None = ..., + app: str | None = ..., + read_consistency: Literal["EVENTUAL"] | None = ..., + read_policy: Literal["EVENTUAL"] | None = ..., + transaction: bytes | None = ..., + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options=..., + ) -> tasklets_module.Future: ... + @classmethod + def get_by_id_async( + cls: Type[Model], + id: int | str, + parent: key_module.Key | None = ..., + namespace: str | None = ..., + project: str | None = ..., + app: str | None = ..., + read_consistency: Literal["EVENTUAL"] | None = ..., + read_policy: Literal["EVENTUAL"] | None = ..., + transaction: bytes | None = ..., + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options=..., + ) -> Model | None: ... + @classmethod + def get_or_insert( + cls: Type[Model], + name: str, + parent: key_module.Key | None = ..., + namespace: str | None = ..., + project: str | None = ..., + app: str | None = ..., + read_consistency: Literal["EVENTUAL"] | None = ..., + read_policy: Literal["EVENTUAL"] | None = ..., + transaction: bytes | None = ..., + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options=..., + **kw_model_args, + ) -> Model: ... + @classmethod + def get_or_insert_async( + cls: Type[Model], + name: str, + parent: key_module.Key | None = ..., + namespace: str | None = ..., + project: str | None = ..., + app: str | None = ..., + read_consistency: Literal["EVENTUAL"] | None = ..., + read_policy: Literal["EVENTUAL"] | None = ..., + transaction: bytes | None = ..., + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options=..., + **kw_model_args, + ) -> tasklets_module.Future: ... + def populate(self, **kwargs) -> None: ... + def has_complete_key(self) -> bool: ... + def to_dict( + self, + include: list[object] | tuple[object, object] | set[object] | None = ..., + exclude: list[object] | tuple[object, object] | set[object] | None = ..., + ): ... + +class Expando(Model): + def __getattr__(self, name: str): ... + def __setattr__(self, name: str, value) -> None: ... + def __delattr__(self, name: str) -> None: ... + +def get_multi_async( + keys: Sequence[Type[key_module.Key]], + read_consistency: Literal["EVENTUAL"] | None = ..., + read_policy: Literal["EVENTUAL"] | None = ..., + transaction: bytes | None = ..., + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options: object | None = ..., +) -> list[Type[tasklets_module.Future]]: ... +def get_multi( + keys: Sequence[Type[key_module.Key]], + read_consistency: Literal["EVENTUAL"] | None = ..., + read_policy: Literal["EVENTUAL"] | None = ..., + transaction: bytes | None = ..., + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options: object | None = ..., +) -> list[Type[Model] | None]: ... +def put_multi_async( + entities: list[Type[Model]], + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options: object | None = ..., +) -> list[tasklets_module.Future]: ... +def put_multi( + entities: list[Model], + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options: object | None = ..., +) -> list[key_module.Key]: ... +def delete_multi_async( + keys: list[key_module.Key], + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options: object | None = ..., +) -> list[tasklets_module.Future]: ... +def delete_multi( + keys: Sequence[key_module.Key], + retries: int | None = ..., + timeout: float | None = ..., + deadline: float | None = ..., + use_cache: bool | None = ..., + use_global_cache: bool | None = ..., + global_cache_timeout: int | None = ..., + use_datastore: bool | None = ..., + use_memcache: bool | None = ..., + memcache_timeout: int | None = ..., + max_memcache_items: int | None = ..., + force_writes: bool | None = ..., + _options: object | None = ..., +) -> list[None]: ... +def get_indexes_async(**options: object) -> NoReturn: ... +def get_indexes(**options: object) -> NoReturn: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/msgprop.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/msgprop.pyi new file mode 100644 index 000000000..2bb3e67d8 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/msgprop.pyi @@ -0,0 +1,5 @@ +class EnumProperty: + def __init__(self, *args, **kwargs) -> None: ... + +class MessageProperty: + def __init__(self, *args, **kwargs) -> None: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/polymodel.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/polymodel.pyi new file mode 100644 index 000000000..43cabd288 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/polymodel.pyi @@ -0,0 +1,9 @@ +from typing import Any + +from google.cloud.ndb import model + +class _ClassKeyProperty(model.StringProperty): + def __init__(self, name=..., indexed: bool = ...) -> None: ... + +class PolyModel(model.Model): + class_: Any diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/query.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/query.pyi new file mode 100644 index 000000000..6ca3d6f33 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/query.pyi @@ -0,0 +1,146 @@ +from typing import Any + +from google.cloud.ndb import _options + +class PropertyOrder: + name: Any + reverse: Any + def __init__(self, name, reverse: bool = ...) -> None: ... + def __neg__(self): ... + +class RepeatedStructuredPropertyPredicate: + name: Any + match_keys: Any + match_values: Any + def __init__(self, name, match_keys, entity_pb) -> None: ... + def __call__(self, entity_pb): ... + +class ParameterizedThing: + def __eq__(self, other): ... + def __ne__(self, other): ... + +class Parameter(ParameterizedThing): + def __init__(self, key) -> None: ... + def __eq__(self, other): ... + @property + def key(self): ... + def resolve(self, bindings, used): ... + +class ParameterizedFunction(ParameterizedThing): + func: Any + values: Any + def __init__(self, func, values) -> None: ... + def __eq__(self, other): ... + def is_parameterized(self): ... + def resolve(self, bindings, used): ... + +class Node: + def __new__(cls): ... + def __eq__(self, other): ... + def __ne__(self, other): ... + def __le__(self, unused_other): ... + def __lt__(self, unused_other): ... + def __ge__(self, unused_other): ... + def __gt__(self, unused_other): ... + def resolve(self, bindings, used): ... + +class FalseNode(Node): + def __eq__(self, other): ... + +class ParameterNode(Node): + def __new__(cls, prop, op, param): ... + def __getnewargs__(self): ... + def __eq__(self, other): ... + def resolve(self, bindings, used): ... + +class FilterNode(Node): + def __new__(cls, name, opsymbol, value): ... + def __getnewargs__(self): ... + def __eq__(self, other): ... + +class PostFilterNode(Node): + def __new__(cls, predicate): ... + def __getnewargs__(self): ... + def __eq__(self, other): ... + +class _BooleanClauses: + name: Any + combine_or: Any + or_parts: Any + def __init__(self, name, combine_or) -> None: ... + def add_node(self, node) -> None: ... + +class ConjunctionNode(Node): + def __new__(cls, *nodes): ... + def __getnewargs__(self): ... + def __iter__(self): ... + def __eq__(self, other): ... + def resolve(self, bindings, used): ... + +class DisjunctionNode(Node): + def __new__(cls, *nodes): ... + def __getnewargs__(self): ... + def __iter__(self): ... + def __eq__(self, other): ... + def resolve(self, bindings, used): ... + +AND = ConjunctionNode +OR = DisjunctionNode + +class QueryOptions(_options.ReadOptions): + project: Any + namespace: Any + def __init__(self, config: Any | None = ..., context: Any | None = ..., **kwargs) -> None: ... + +class Query: + default_options: Any + kind: Any + ancestor: Any + filters: Any + order_by: Any + project: Any + namespace: Any + limit: Any + offset: Any + keys_only: Any + projection: Any + distinct_on: Any + def __init__( + self, + kind: Any | None = ..., + filters: Any | None = ..., + ancestor: Any | None = ..., + order_by: Any | None = ..., + orders: Any | None = ..., + project: Any | None = ..., + app: Any | None = ..., + namespace: Any | None = ..., + projection: Any | None = ..., + distinct_on: Any | None = ..., + group_by: Any | None = ..., + limit: Any | None = ..., + offset: Any | None = ..., + keys_only: Any | None = ..., + default_options: Any | None = ..., + ) -> None: ... + @property + def is_distinct(self): ... + def filter(self, *filters): ... + def order(self, *props): ... + def analyze(self): ... + def bind(self, *positional, **keyword): ... + def fetch(self, limit: Any | None = ..., **kwargs): ... + def fetch_async(self, limit: Any | None = ..., **kwargs): ... + def run_to_queue(self, queue, conn, options: Any | None = ..., dsquery: Any | None = ...) -> None: ... + def iter(self, **kwargs): ... + __iter__: Any + def map(self, callback, **kwargs): ... + def map_async(self, callback, **kwargs) -> None: ... + def get(self, **kwargs): ... + def get_async(self, **kwargs) -> None: ... + def count(self, limit: Any | None = ..., **kwargs): ... + def count_async(self, limit: Any | None = ..., **kwargs): ... + def fetch_page(self, page_size, **kwargs): ... + def fetch_page_async(self, page_size, **kwargs) -> None: ... + +def gql(query_string: str, *args: Any, **kwds: Any) -> Query: ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/stats.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/stats.pyi new file mode 100644 index 000000000..1ffa02ff0 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/stats.pyi @@ -0,0 +1,102 @@ +from typing import Any + +from google.cloud.ndb import model + +class BaseStatistic(model.Model): + STORED_KIND_NAME: str + bytes: Any + count: Any + timestamp: Any + +class BaseKindStatistic(BaseStatistic): + STORED_KIND_NAME: str + kind_name: Any + entity_bytes: Any + +class GlobalStat(BaseStatistic): + STORED_KIND_NAME: str + entity_bytes: Any + builtin_index_bytes: Any + builtin_index_count: Any + composite_index_bytes: Any + composite_index_count: Any + +class NamespaceStat(BaseStatistic): + STORED_KIND_NAME: str + subject_namespace: Any + entity_bytes: Any + builtin_index_bytes: Any + builtin_index_count: Any + composite_index_bytes: Any + composite_index_count: Any + +class KindStat(BaseKindStatistic): + STORED_KIND_NAME: str + builtin_index_bytes: Any + builtin_index_count: Any + composite_index_bytes: Any + composite_index_count: Any + +class KindRootEntityStat(BaseKindStatistic): + STORED_KIND_NAME: str + +class KindNonRootEntityStat(BaseKindStatistic): + STORED_KIND_NAME: str + +class PropertyTypeStat(BaseStatistic): + STORED_KIND_NAME: str + property_type: Any + entity_bytes: Any + builtin_index_bytes: Any + builtin_index_count: Any + +class KindPropertyTypeStat(BaseKindStatistic): + STORED_KIND_NAME: str + property_type: Any + builtin_index_bytes: Any + builtin_index_count: Any + +class KindPropertyNameStat(BaseKindStatistic): + STORED_KIND_NAME: str + property_name: Any + builtin_index_bytes: Any + builtin_index_count: Any + +class KindPropertyNamePropertyTypeStat(BaseKindStatistic): + STORED_KIND_NAME: str + property_type: Any + property_name: Any + builtin_index_bytes: Any + builtin_index_count: Any + +class KindCompositeIndexStat(BaseStatistic): + STORED_KIND_NAME: str + index_id: Any + kind_name: Any + +class NamespaceGlobalStat(GlobalStat): + STORED_KIND_NAME: str + +class NamespaceKindStat(KindStat): + STORED_KIND_NAME: str + +class NamespaceKindRootEntityStat(KindRootEntityStat): + STORED_KIND_NAME: str + +class NamespaceKindNonRootEntityStat(KindNonRootEntityStat): + STORED_KIND_NAME: str + +class NamespacePropertyTypeStat(PropertyTypeStat): + STORED_KIND_NAME: str + +class NamespaceKindPropertyTypeStat(KindPropertyTypeStat): + STORED_KIND_NAME: str + +class NamespaceKindPropertyNameStat(KindPropertyNameStat): + STORED_KIND_NAME: str + +class NamespaceKindPropertyNamePropertyTypeStat(KindPropertyNamePropertyTypeStat): + STORED_KIND_NAME: str + +class NamespaceKindCompositeIndexStat(KindCompositeIndexStat): + STORED_KIND_NAME: str diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/tasklets.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/tasklets.pyi new file mode 100644 index 000000000..4d9f34d69 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/tasklets.pyi @@ -0,0 +1,58 @@ +from typing import Any + +class Future: + info: Any + def __init__(self, info: str = ...) -> None: ... + def done(self): ... + def running(self): ... + def wait(self) -> None: ... + def check_success(self) -> None: ... + def set_result(self, result) -> None: ... + def set_exception(self, exception) -> None: ... + def result(self): ... + get_result: Any + def exception(self): ... + get_exception: Any + def get_traceback(self): ... + def add_done_callback(self, callback) -> None: ... + def cancel(self) -> None: ... + def cancelled(self): ... + @staticmethod + def wait_any(futures): ... + @staticmethod + def wait_all(futures): ... + +class _TaskletFuture(Future): + generator: Any + context: Any + waiting_on: Any + def __init__(self, generator, context, info: str = ...) -> None: ... + def cancel(self) -> None: ... + +class _MultiFuture(Future): + def __init__(self, dependencies) -> None: ... + def cancel(self) -> None: ... + +def tasklet(wrapped): ... +def wait_any(futures): ... +def wait_all(futures) -> None: ... + +class Return(Exception): ... + +def sleep(seconds): ... +def add_flow_exception(*args, **kwargs) -> None: ... +def make_context(*args, **kwargs) -> None: ... +def make_default_context(*args, **kwargs) -> None: ... + +class QueueFuture: + def __init__(self, *args, **kwargs) -> None: ... + +class ReducingFuture: + def __init__(self, *args, **kwargs) -> None: ... + +class SerialQueueFuture: + def __init__(self, *args, **kwargs) -> None: ... + +def set_context(*args, **kwargs) -> None: ... +def synctasklet(wrapped): ... +def toplevel(wrapped): ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/utils.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/utils.pyi new file mode 100644 index 000000000..3ddb96071 --- /dev/null +++ b/stubs/google-cloud-ndb/google/cloud/ndb/utils.pyi @@ -0,0 +1,28 @@ +import threading +from typing import Any + +TRUTHY_STRINGS: Any + +def asbool(value): ... + +DEBUG: Any + +def code_info(*args, **kwargs) -> None: ... +def decorator(*args, **kwargs) -> None: ... +def frame_info(*args, **kwargs) -> None: ... +def func_info(*args, **kwargs) -> None: ... +def gen_info(*args, **kwargs) -> None: ... +def get_stack(*args, **kwargs) -> None: ... +def logging_debug(log, message, *args, **kwargs) -> None: ... + +class keyword_only: + defaults: Any + def __init__(self, **kwargs) -> None: ... + def __call__(self, wrapped): ... + +def positional(max_pos_args): ... + +threading_local = threading.local + +def tweak_logging(*args, **kwargs) -> None: ... +def wrapping(*args, **kwargs) -> None: ...