|
| 1 | +# Copyright 2020 Google Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# This module adds some type annotations that refer to types defined in other |
| 16 | +# submodules. To avoid circular import issues (NameError), the evaluation of |
| 17 | +# these annotations is deferred by using string literals (forward references). |
| 18 | +# This allows the annotations to be valid at runtime without requiring the immediate |
| 19 | +# loading of the referenced symbols. |
| 20 | + |
| 21 | +import typing |
| 22 | +import typing_extensions |
| 23 | + |
| 24 | +import google.auth.credentials |
| 25 | +import requests |
| 26 | + |
| 27 | +import firebase_admin |
| 28 | +from firebase_admin import credentials |
| 29 | +from firebase_admin import exceptions |
| 30 | +from firebase_admin import project_management |
| 31 | + |
| 32 | + |
| 33 | +_KT = typing.TypeVar("_KT") |
| 34 | +_VT_co = typing.TypeVar("_VT_co", covariant=True) |
| 35 | + |
| 36 | + |
| 37 | +class SupportsKeysAndGetItem(typing.Protocol[_KT, _VT_co]): |
| 38 | + def keys(self) -> typing.Iterable[_KT]: ... |
| 39 | + def __getitem__(self, __key: _KT) -> _VT_co: ... |
| 40 | + |
| 41 | + |
| 42 | +class SupportsTrunc(typing.Protocol): |
| 43 | + def __trunc__(self) -> int: ... |
| 44 | + |
| 45 | + |
| 46 | +ConvertibleToInt = typing.Union[ |
| 47 | + str, |
| 48 | + typing_extensions.Buffer, |
| 49 | + typing.SupportsInt, |
| 50 | + typing.SupportsIndex, |
| 51 | + SupportsTrunc |
| 52 | +] |
| 53 | +ConvertibleToFloat: typing_extensions.TypeAlias = typing.Union[ |
| 54 | + str, |
| 55 | + typing_extensions.Buffer, |
| 56 | + typing.SupportsFloat, |
| 57 | + typing.SupportsIndex |
| 58 | +] |
| 59 | + |
| 60 | +_AnyT = typing_extensions.TypeVar("_AnyT", default=typing.Any) |
| 61 | +_AnyT_co = typing_extensions.TypeVar("_AnyT_co", covariant=True, default=typing.Any) |
| 62 | + |
| 63 | +_FirebaseErrorT_co = typing_extensions.TypeVar( |
| 64 | + "_FirebaseErrorT_co", covariant=True, default="exceptions.FirebaseError") |
| 65 | +_AppMetadataT_co = typing_extensions.TypeVar( |
| 66 | + "_AppMetadataT_co", covariant=True, default="project_management._AppMetadata") |
| 67 | + |
| 68 | +CredentialLike = typing.Union["credentials.Base", google.auth.credentials.Credentials] |
| 69 | +HeadersLike = typing.Union[ |
| 70 | + SupportsKeysAndGetItem[str, typing.Union[bytes, str]], |
| 71 | + typing.Iterable[typing.Tuple[str, typing.Union[bytes, str]]] |
| 72 | +] |
| 73 | +ServiceInitializer = typing.Callable[["firebase_admin.App"], _AnyT] |
| 74 | +RequestErrorHandler = typing.Callable[ |
| 75 | + [ |
| 76 | + requests.RequestException, |
| 77 | + str, |
| 78 | + typing.Dict[str, typing.Any] |
| 79 | + ], |
| 80 | + typing.Optional["exceptions.FirebaseError"] |
| 81 | +] |
| 82 | +GoogleAPIErrorHandler = typing.Callable[ |
| 83 | + [ |
| 84 | + Exception, |
| 85 | + str, |
| 86 | + typing.Dict[str, typing.Any], |
| 87 | + requests.Response, |
| 88 | + ], |
| 89 | + typing.Optional["exceptions.FirebaseError"], |
| 90 | +] |
| 91 | +Json = typing.Optional[typing.Union[ |
| 92 | + typing.Dict[str, "Json"], |
| 93 | + typing.List["Json"], |
| 94 | + str, |
| 95 | + float |
| 96 | +]] |
| 97 | +EmailActionType = typing.Literal[ |
| 98 | + 'VERIFY_EMAIL', |
| 99 | + 'EMAIL_SIGNIN', |
| 100 | + 'PASSWORD_RESET', |
| 101 | +] |
| 102 | + |
| 103 | +class FirebaseErrorFactory(typing.Protocol[_FirebaseErrorT_co]): |
| 104 | + def __call__( |
| 105 | + self, |
| 106 | + message: str, |
| 107 | + cause: typing.Optional[Exception], |
| 108 | + http_response: typing.Optional[requests.Response], |
| 109 | + ) -> _FirebaseErrorT_co: ... |
| 110 | + |
| 111 | + |
| 112 | +class FirebaseErrorFactoryNoHttp(typing.Protocol[_FirebaseErrorT_co]): |
| 113 | + def __call__( |
| 114 | + self, |
| 115 | + message: str, |
| 116 | + cause: typing.Optional[Exception], |
| 117 | + ) -> _FirebaseErrorT_co: ... |
| 118 | + |
| 119 | + |
| 120 | +class FirebaseErrorFactoryWithDefaults(typing.Protocol[_FirebaseErrorT_co]): |
| 121 | + def __call__( |
| 122 | + self, |
| 123 | + message: str, |
| 124 | + cause: typing.Optional[Exception] = None, |
| 125 | + http_response: typing.Optional[requests.Response] = None, |
| 126 | + ) -> _FirebaseErrorT_co: ... |
| 127 | + |
| 128 | + |
| 129 | +class FirebaseErrorFactoryNoHttpWithDefaults(typing.Protocol[_FirebaseErrorT_co]): |
| 130 | + def __call__( |
| 131 | + self, |
| 132 | + message: str, |
| 133 | + cause: typing.Optional[Exception] = None, |
| 134 | + ) -> _FirebaseErrorT_co: ... |
| 135 | + |
| 136 | + |
| 137 | +class AppMetadataSubclass(typing.Protocol[_AppMetadataT_co]): |
| 138 | + def __call__( |
| 139 | + self, |
| 140 | + __identifier: str, |
| 141 | + name: str, |
| 142 | + app_id: str, |
| 143 | + display_name: typing.Optional[str], |
| 144 | + project_id: str |
| 145 | + ) -> _AppMetadataT_co: ... |
| 146 | + |
| 147 | + |
| 148 | +class ProjectApp(typing.Protocol[_AnyT_co]): |
| 149 | + def __call__( |
| 150 | + self, |
| 151 | + app_id: str, |
| 152 | + service: "project_management._ProjectManagementService", |
| 153 | + ) -> _AnyT_co: ... |
| 154 | + |
| 155 | + |
| 156 | +class Page(typing.Protocol): |
| 157 | + @property |
| 158 | + def has_next_page(self) -> bool: ... |
| 159 | + |
| 160 | + def get_next_page(self) -> typing.Optional[typing_extensions.Self]: ... |
0 commit comments