massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stubs / google-cloud-ndb / google / cloud / ndb / model.pyi
1 import datetime
2 from collections.abc import Iterable, Sequence
3 from typing import Callable, NoReturn, Type
4 from typing_extensions import Literal
5
6 from google.cloud.ndb import exceptions, key as key_module, query as query_module, tasklets as tasklets_module
7
8 Key = key_module.Key
9 Rollback = exceptions.Rollback
10 BlobKey: object
11 GeoPt: object
12
13 class KindError(exceptions.BadValueError): ...
14 class InvalidPropertyError(exceptions.Error): ...
15
16 BadProjectionError = InvalidPropertyError
17
18 class UnprojectedPropertyError(exceptions.Error): ...
19 class ReadonlyPropertyError(exceptions.Error): ...
20 class ComputedPropertyError(ReadonlyPropertyError): ...
21 class UserNotFoundError(exceptions.Error): ...
22
23 class _NotEqualMixin:
24     def __ne__(self, other: object) -> bool: ...
25
26 DirectionT = Literal["asc", "desc"]
27
28 class IndexProperty(_NotEqualMixin):
29     def __new__(cls, name: str, direction: DirectionT) -> IndexProperty: ...
30     @property
31     def name(self) -> str: ...
32     @property
33     def direction(self) -> DirectionT: ...
34     def __eq__(self, other: object) -> bool: ...
35     def __hash__(self) -> int: ...
36
37 class Index(_NotEqualMixin):
38     def __new__(cls, kind: str, properties: list[IndexProperty], ancestor: bool) -> Index: ...
39     @property
40     def kind(self) -> str: ...
41     @property
42     def properties(self) -> list[IndexProperty]: ...
43     @property
44     def ancestor(self) -> bool: ...
45     def __eq__(self, other) -> bool: ...
46     def __hash__(self) -> int: ...
47
48 class IndexState(_NotEqualMixin):
49     def __new__(cls, definition, state, id): ...
50     @property
51     def definition(self): ...
52     @property
53     def state(self): ...
54     @property
55     def id(self): ...
56     def __eq__(self, other) -> bool: ...
57     def __hash__(self) -> int: ...
58
59 class ModelAdapter:
60     def __new__(cls, *args, **kwargs) -> ModelAdapter: ...
61
62 def make_connection(*args, **kwargs) -> NoReturn: ...
63
64 class ModelAttribute: ...
65
66 class _BaseValue(_NotEqualMixin):
67     b_val: object = ...
68     def __init__(self, b_val) -> None: ...
69     def __eq__(self, other) -> bool: ...
70     def __hash__(self) -> int: ...
71
72 class Property(ModelAttribute):
73     def __init__(
74         self,
75         name: str | None = ...,
76         indexed: bool | None = ...,
77         repeated: bool | None = ...,
78         required: bool | None = ...,
79         default: object | None = ...,
80         choices: Iterable[object] | None = ...,
81         validator: Callable[[Property], object] | None = ...,
82         verbose_name: str | None = ...,
83         write_empty_list: bool | None = ...,
84     ) -> None: ...
85     def __eq__(self, value: object) -> query_module.FilterNode: ...  # type: ignore[override]
86     def __ne__(self, value: object) -> query_module.FilterNode: ...  # type: ignore[override]
87     def __lt__(self, value: object) -> query_module.FilterNode: ...
88     def __le__(self, value: object) -> query_module.FilterNode: ...
89     def __gt__(self, value: object) -> query_module.FilterNode: ...
90     def __ge__(self, value: object) -> query_module.FilterNode: ...
91     def IN(self, value: Iterable[object]) -> query_module.DisjunctionNode | query_module.FilterNode | query_module.FalseNode: ...
92     def __neg__(self) -> query_module.PropertyOrder: ...
93     def __pos__(self) -> query_module.PropertyOrder: ...
94     def __set__(self, entity: Model, value: object) -> None: ...
95     def __delete__(self, entity: Model) -> None: ...
96
97 class ModelKey(Property):
98     def __init__(self) -> None: ...
99     def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> key_module.Key | list[key_module.Key] | None: ...
100
101 class BooleanProperty(Property):
102     def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> bool | list[bool] | None: ...
103
104 class IntegerProperty(Property):
105     def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> int | list[int] | None: ...
106
107 class FloatProperty(Property):
108     def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> float | list[float] | None: ...
109
110 class _CompressedValue(bytes):
111     z_val: bytes = ...
112     def __init__(self, z_val: bytes) -> None: ...
113     def __eq__(self, other: object) -> bool: ...
114     def __hash__(self) -> NoReturn: ...
115
116 class BlobProperty(Property):
117     def __init__(
118         self,
119         name: str | None = ...,
120         compressed: bool | None = ...,
121         indexed: bool | None = ...,
122         repeated: bool | None = ...,
123         required: bool | None = ...,
124         default: bytes | None = ...,
125         choices: Iterable[bytes] | None = ...,
126         validator: Callable[[Property], object] | None = ...,
127         verbose_name: str | None = ...,
128         write_empty_list: bool | None = ...,
129     ) -> None: ...
130     def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> bytes | list[bytes] | None: ...
131
132 class CompressedTextProperty(BlobProperty):
133     def __init__(self, *args, **kwargs) -> None: ...
134
135 class TextProperty(Property):
136     def __new__(cls, *args, **kwargs): ...
137     def __init__(self, *args, **kwargs) -> None: ...
138     def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> str | list[str] | None: ...
139
140 class StringProperty(TextProperty):
141     def __init__(self, *args, **kwargs) -> None: ...
142
143 class GeoPtProperty(Property): ...
144 class PickleProperty(BlobProperty): ...
145
146 class JsonProperty(BlobProperty):
147     def __init__(
148         self,
149         name: str | None = ...,
150         compressed: bool | None = ...,
151         json_type: type | None = ...,
152         indexed: bool | None = ...,
153         repeated: bool | None = ...,
154         required: bool | None = ...,
155         default: object | None = ...,
156         choices: Iterable[object] | None = ...,
157         validator: Callable[[Property], object] | None = ...,
158         verbose_name: str | None = ...,
159         write_empty_list: bool | None = ...,
160     ) -> None: ...
161
162 class User:
163     def __init__(self, email: str | None = ..., _auth_domain: str | None = ..., _user_id: str | None = ...) -> None: ...
164     def nickname(self) -> str: ...
165     def email(self): ...
166     def user_id(self) -> str | None: ...
167     def auth_domain(self) -> str: ...
168     def __hash__(self) -> int: ...
169     def __eq__(self, other: object) -> bool: ...
170     def __lt__(self, other: object) -> bool: ...
171
172 class UserProperty(Property):
173     def __init__(
174         self,
175         name: str | None = ...,
176         auto_current_user: bool | None = ...,
177         auto_current_user_add: bool | None = ...,
178         indexed: bool | None = ...,
179         repeated: bool | None = ...,
180         required: bool | None = ...,
181         default: bytes | None = ...,
182         choices: Iterable[bytes] | None = ...,
183         validator: Callable[[Property], object] | None = ...,
184         verbose_name: str | None = ...,
185         write_empty_list: bool | None = ...,
186     ) -> None: ...
187
188 class KeyProperty(Property):
189     def __init__(
190         self,
191         name: str | None = ...,
192         kind: Type[Model] | str | None = ...,
193         indexed: bool | None = ...,
194         repeated: bool | None = ...,
195         required: bool | None = ...,
196         default: key_module.Key | None = ...,
197         choices: Iterable[key_module.Key] | None = ...,
198         validator: Callable[[Property, key_module.Key], bool] | None = ...,
199         verbose_name: str | None = ...,
200         write_empty_list: bool | None = ...,
201     ) -> None: ...
202
203 class BlobKeyProperty(Property): ...
204
205 class DateTimeProperty(Property):
206     def __init__(
207         self,
208         name: str | None = ...,
209         auto_now: bool | None = ...,
210         auto_now_add: bool | None = ...,
211         tzinfo: datetime.tzinfo | None = ...,
212         indexed: bool | None = ...,
213         repeated: bool | None = ...,
214         required: bool | None = ...,
215         default: datetime.datetime | None = ...,
216         choices: Iterable[datetime.datetime] | None = ...,
217         validator: Callable[[Property, object], bool] | None = ...,
218         verbose_name: str | None = ...,
219         write_empty_list: bool | None = ...,
220     ) -> None: ...
221
222 class DateProperty(DateTimeProperty): ...
223 class TimeProperty(DateTimeProperty): ...
224
225 class StructuredProperty(Property):
226     def __init__(self, model_class: type, name: str | None = ..., **kwargs) -> None: ...
227     def __getattr__(self, attrname): ...
228     def IN(self, value: Iterable[object]) -> query_module.DisjunctionNode | query_module.FalseNode: ...
229
230 class LocalStructuredProperty(BlobProperty):
231     def __init__(self, model_class: Type[Model], **kwargs) -> None: ...
232
233 class GenericProperty(Property):
234     def __init__(self, name: str | None = ..., compressed: bool = ..., **kwargs) -> None: ...
235
236 class ComputedProperty(GenericProperty):
237     def __init__(
238         self,
239         func: Callable[[Model], object],
240         name: str | None = ...,
241         indexed: bool | None = ...,
242         repeated: bool | None = ...,
243         verbose_name: str | None = ...,
244     ) -> None: ...
245
246 class MetaModel(type):
247     def __init__(cls, name: str, bases, classdict) -> None: ...
248
249 class Model(_NotEqualMixin, metaclass=MetaModel):
250     key: ModelKey = ...
251     def __init__(_self, **kwargs) -> None: ...
252     def __hash__(self) -> NoReturn: ...
253     def __eq__(self, other: object) -> bool: ...
254     @classmethod
255     def gql(cls: Type[Model], query_string: str, *args, **kwargs) -> query_module.Query: ...
256     def put(self, **kwargs): ...
257     def put_async(self, **kwargs) -> tasklets_module.Future: ...
258     @classmethod
259     def query(cls: Type[Model], *args, **kwargs) -> query_module.Query: ...
260     @classmethod
261     def allocate_ids(
262         cls: Type[Model],
263         size: int | None = ...,
264         max: int | None = ...,
265         parent: key_module.Key | None = ...,
266         retries: int | None = ...,
267         timeout: float | None = ...,
268         deadline: float | None = ...,
269         use_cache: bool | None = ...,
270         use_global_cache: bool | None = ...,
271         global_cache_timeout: int | None = ...,
272         use_datastore: bool | None = ...,
273         use_memcache: bool | None = ...,
274         memcache_timeout: int | None = ...,
275         max_memcache_items: int | None = ...,
276         force_writes: bool | None = ...,
277         _options=...,
278     ) -> tuple[key_module.Key, key_module.Key]: ...
279     @classmethod
280     def allocate_ids_async(
281         cls: Type[Model],
282         size: int | None = ...,
283         max: int | None = ...,
284         parent: key_module.Key | None = ...,
285         retries: int | None = ...,
286         timeout: float | None = ...,
287         deadline: float | None = ...,
288         use_cache: bool | None = ...,
289         use_global_cache: bool | None = ...,
290         global_cache_timeout: int | None = ...,
291         use_datastore: bool | None = ...,
292         use_memcache: bool | None = ...,
293         memcache_timeout: int | None = ...,
294         max_memcache_items: int | None = ...,
295         force_writes: bool | None = ...,
296         _options=...,
297     ) -> tasklets_module.Future: ...
298     @classmethod
299     def get_by_id(
300         cls: Type[Model],
301         id: int | str | None,
302         parent: key_module.Key | None = ...,
303         namespace: str | None = ...,
304         project: str | None = ...,
305         app: str | None = ...,
306         read_consistency: Literal["EVENTUAL"] | None = ...,
307         read_policy: Literal["EVENTUAL"] | None = ...,
308         transaction: bytes | None = ...,
309         retries: int | None = ...,
310         timeout: float | None = ...,
311         deadline: float | None = ...,
312         use_cache: bool | None = ...,
313         use_global_cache: bool | None = ...,
314         global_cache_timeout: int | None = ...,
315         use_datastore: bool | None = ...,
316         use_memcache: bool | None = ...,
317         memcache_timeout: int | None = ...,
318         max_memcache_items: int | None = ...,
319         force_writes: bool | None = ...,
320         _options=...,
321     ) -> tasklets_module.Future: ...
322     @classmethod
323     def get_by_id_async(
324         cls: Type[Model],
325         id: int | str,
326         parent: key_module.Key | None = ...,
327         namespace: str | None = ...,
328         project: str | None = ...,
329         app: str | None = ...,
330         read_consistency: Literal["EVENTUAL"] | None = ...,
331         read_policy: Literal["EVENTUAL"] | None = ...,
332         transaction: bytes | None = ...,
333         retries: int | None = ...,
334         timeout: float | None = ...,
335         deadline: float | None = ...,
336         use_cache: bool | None = ...,
337         use_global_cache: bool | None = ...,
338         global_cache_timeout: int | None = ...,
339         use_datastore: bool | None = ...,
340         use_memcache: bool | None = ...,
341         memcache_timeout: int | None = ...,
342         max_memcache_items: int | None = ...,
343         force_writes: bool | None = ...,
344         _options=...,
345     ) -> Model | None: ...
346     @classmethod
347     def get_or_insert(
348         cls: Type[Model],
349         name: str,
350         parent: key_module.Key | None = ...,
351         namespace: str | None = ...,
352         project: str | None = ...,
353         app: str | None = ...,
354         read_consistency: Literal["EVENTUAL"] | None = ...,
355         read_policy: Literal["EVENTUAL"] | None = ...,
356         transaction: bytes | None = ...,
357         retries: int | None = ...,
358         timeout: float | None = ...,
359         deadline: float | None = ...,
360         use_cache: bool | None = ...,
361         use_global_cache: bool | None = ...,
362         global_cache_timeout: int | None = ...,
363         use_datastore: bool | None = ...,
364         use_memcache: bool | None = ...,
365         memcache_timeout: int | None = ...,
366         max_memcache_items: int | None = ...,
367         force_writes: bool | None = ...,
368         _options=...,
369         **kw_model_args,
370     ) -> Model: ...
371     @classmethod
372     def get_or_insert_async(
373         cls: Type[Model],
374         name: str,
375         parent: key_module.Key | None = ...,
376         namespace: str | None = ...,
377         project: str | None = ...,
378         app: str | None = ...,
379         read_consistency: Literal["EVENTUAL"] | None = ...,
380         read_policy: Literal["EVENTUAL"] | None = ...,
381         transaction: bytes | None = ...,
382         retries: int | None = ...,
383         timeout: float | None = ...,
384         deadline: float | None = ...,
385         use_cache: bool | None = ...,
386         use_global_cache: bool | None = ...,
387         global_cache_timeout: int | None = ...,
388         use_datastore: bool | None = ...,
389         use_memcache: bool | None = ...,
390         memcache_timeout: int | None = ...,
391         max_memcache_items: int | None = ...,
392         force_writes: bool | None = ...,
393         _options=...,
394         **kw_model_args,
395     ) -> tasklets_module.Future: ...
396     def populate(self, **kwargs) -> None: ...
397     def has_complete_key(self) -> bool: ...
398     def to_dict(
399         self,
400         include: list[object] | tuple[object, object] | set[object] | None = ...,
401         exclude: list[object] | tuple[object, object] | set[object] | None = ...,
402     ): ...
403
404 class Expando(Model):
405     def __getattr__(self, name: str): ...
406     def __setattr__(self, name: str, value) -> None: ...
407     def __delattr__(self, name: str) -> None: ...
408
409 def get_multi_async(
410     keys: Sequence[Type[key_module.Key]],
411     read_consistency: Literal["EVENTUAL"] | None = ...,
412     read_policy: Literal["EVENTUAL"] | None = ...,
413     transaction: bytes | None = ...,
414     retries: int | None = ...,
415     timeout: float | None = ...,
416     deadline: float | None = ...,
417     use_cache: bool | None = ...,
418     use_global_cache: bool | None = ...,
419     global_cache_timeout: int | None = ...,
420     use_datastore: bool | None = ...,
421     use_memcache: bool | None = ...,
422     memcache_timeout: int | None = ...,
423     max_memcache_items: int | None = ...,
424     force_writes: bool | None = ...,
425     _options: object | None = ...,
426 ) -> list[Type[tasklets_module.Future]]: ...
427 def get_multi(
428     keys: Sequence[Type[key_module.Key]],
429     read_consistency: Literal["EVENTUAL"] | None = ...,
430     read_policy: Literal["EVENTUAL"] | None = ...,
431     transaction: bytes | None = ...,
432     retries: int | None = ...,
433     timeout: float | None = ...,
434     deadline: float | None = ...,
435     use_cache: bool | None = ...,
436     use_global_cache: bool | None = ...,
437     global_cache_timeout: int | None = ...,
438     use_datastore: bool | None = ...,
439     use_memcache: bool | None = ...,
440     memcache_timeout: int | None = ...,
441     max_memcache_items: int | None = ...,
442     force_writes: bool | None = ...,
443     _options: object | None = ...,
444 ) -> list[Type[Model] | None]: ...
445 def put_multi_async(
446     entities: list[Type[Model]],
447     retries: int | None = ...,
448     timeout: float | None = ...,
449     deadline: float | None = ...,
450     use_cache: bool | None = ...,
451     use_global_cache: bool | None = ...,
452     global_cache_timeout: int | None = ...,
453     use_datastore: bool | None = ...,
454     use_memcache: bool | None = ...,
455     memcache_timeout: int | None = ...,
456     max_memcache_items: int | None = ...,
457     force_writes: bool | None = ...,
458     _options: object | None = ...,
459 ) -> list[tasklets_module.Future]: ...
460 def put_multi(
461     entities: list[Model],
462     retries: int | None = ...,
463     timeout: float | None = ...,
464     deadline: float | None = ...,
465     use_cache: bool | None = ...,
466     use_global_cache: bool | None = ...,
467     global_cache_timeout: int | None = ...,
468     use_datastore: bool | None = ...,
469     use_memcache: bool | None = ...,
470     memcache_timeout: int | None = ...,
471     max_memcache_items: int | None = ...,
472     force_writes: bool | None = ...,
473     _options: object | None = ...,
474 ) -> list[key_module.Key]: ...
475 def delete_multi_async(
476     keys: list[key_module.Key],
477     retries: int | None = ...,
478     timeout: float | None = ...,
479     deadline: float | None = ...,
480     use_cache: bool | None = ...,
481     use_global_cache: bool | None = ...,
482     global_cache_timeout: int | None = ...,
483     use_datastore: bool | None = ...,
484     use_memcache: bool | None = ...,
485     memcache_timeout: int | None = ...,
486     max_memcache_items: int | None = ...,
487     force_writes: bool | None = ...,
488     _options: object | None = ...,
489 ) -> list[tasklets_module.Future]: ...
490 def delete_multi(
491     keys: Sequence[key_module.Key],
492     retries: int | None = ...,
493     timeout: float | None = ...,
494     deadline: float | None = ...,
495     use_cache: bool | None = ...,
496     use_global_cache: bool | None = ...,
497     global_cache_timeout: int | None = ...,
498     use_datastore: bool | None = ...,
499     use_memcache: bool | None = ...,
500     memcache_timeout: int | None = ...,
501     max_memcache_items: int | None = ...,
502     force_writes: bool | None = ...,
503     _options: object | None = ...,
504 ) -> list[None]: ...
505 def get_indexes_async(**options: object) -> NoReturn: ...
506 def get_indexes(**options: object) -> NoReturn: ...