|
| 1 | +from _typeshed import SupportsItems |
| 2 | +from collections.abc import Iterable, Iterator, KeysView, Mapping, Sequence |
1 | 3 | from datetime import datetime, timedelta, tzinfo
|
2 | 4 | from typing import Any as tAny
|
| 5 | +from typing_extensions import TypeAlias |
| 6 | + |
| 7 | +from google.protobuf import struct_pb2 |
3 | 8 |
|
4 | 9 | class Any:
|
5 | 10 | type_url: tAny = ...
|
@@ -63,29 +68,34 @@ class _FieldMaskTree:
|
63 | 68 | def AddLeafNodes(self, prefix: tAny, node: tAny) -> None: ...
|
64 | 69 | def MergeMessage(self, source: tAny, destination: tAny, replace_message: tAny, replace_repeated: tAny) -> None: ...
|
65 | 70 |
|
| 71 | +_StructValue: TypeAlias = struct_pb2.Struct | struct_pb2.ListValue | str | float | bool | None |
| 72 | +_StructValueArg: TypeAlias = _StructValue | Mapping[str, _StructValueArg] | Sequence[_StructValueArg] |
| 73 | + |
66 | 74 | class Struct:
|
67 |
| - def __getitem__(self, key: tAny): ... |
68 |
| - def __contains__(self, item: tAny): ... |
69 |
| - def __setitem__(self, key: tAny, value: tAny) -> None: ... |
70 |
| - def __delitem__(self, key: tAny) -> None: ... |
| 75 | + def __getitem__(self, key: str) -> _StructValue: ... |
| 76 | + def __contains__(self, item: object) -> bool: ... |
| 77 | + def __setitem__(self, key: str, value: _StructValueArg) -> None: ... |
| 78 | + def __delitem__(self, key: str) -> None: ... |
71 | 79 | def __len__(self) -> int: ...
|
72 |
| - def __iter__(self): ... |
73 |
| - def keys(self): ... |
74 |
| - def values(self): ... |
75 |
| - def items(self): ... |
76 |
| - def get_or_create_list(self, key: tAny): ... |
77 |
| - def get_or_create_struct(self, key: tAny): ... |
78 |
| - def update(self, dictionary: tAny) -> None: ... |
| 80 | + def __iter__(self) -> Iterator[str]: ... |
| 81 | + def keys(self) -> KeysView[str]: ... |
| 82 | + def values(self) -> list[_StructValue]: ... |
| 83 | + def items(self) -> list[tuple[str, _StructValue]]: ... |
| 84 | + def get_or_create_list(self, key: str) -> struct_pb2.ListValue: ... |
| 85 | + def get_or_create_struct(self, key: str) -> struct_pb2.Struct: ... |
| 86 | + def update(self, dictionary: SupportsItems[str, _StructValueArg]) -> None: ... |
79 | 87 |
|
80 | 88 | class ListValue:
|
81 | 89 | def __len__(self) -> int: ...
|
82 |
| - def append(self, value: tAny) -> None: ... |
83 |
| - def extend(self, elem_seq: tAny) -> None: ... |
84 |
| - def __getitem__(self, index: tAny): ... |
85 |
| - def __setitem__(self, index: tAny, value: tAny) -> None: ... |
86 |
| - def __delitem__(self, key: tAny) -> None: ... |
87 |
| - def items(self) -> None: ... |
88 |
| - def add_struct(self): ... |
89 |
| - def add_list(self): ... |
| 90 | + def append(self, value: _StructValue) -> None: ... |
| 91 | + def extend(self, elem_seq: Iterable[_StructValue]) -> None: ... |
| 92 | + def __getitem__(self, index: int) -> _StructValue: ... |
| 93 | + def __setitem__(self, index: int, value: _StructValueArg) -> None: ... |
| 94 | + def __delitem__(self, key: int) -> None: ... |
| 95 | + # Doesn't actually exist at runtime; needed so type checkers understand the class is iterable |
| 96 | + def __iter__(self) -> Iterator[_StructValue]: ... |
| 97 | + def items(self) -> Iterator[_StructValue]: ... |
| 98 | + def add_struct(self) -> struct_pb2.Struct: ... |
| 99 | + def add_list(self) -> struct_pb2.ListValue: ... |
90 | 100 |
|
91 | 101 | WKTBASES: dict[str, type[tAny]]
|
0 commit comments