|
2 | 2 | from copy import copy, deepcopy |
3 | 3 | from dataclasses import asdict |
4 | 4 | from pathlib import Path |
| 5 | +from typing import Dict, List, Union |
5 | 6 | from urllib.parse import parse_qs, urlparse |
6 | 7 |
|
7 | 8 | import json_merge_patch |
|
17 | 18 | from .metadata_update import apply_update_patch |
18 | 19 | from .utils import MSGPACK_MIME_TYPE, handle_error, retry_context |
19 | 20 |
|
| 21 | +# TODO: Duplicated from tiled.type_aliases to prevent importing numpy |
| 22 | +# After #1407 replace AnyAdapter with the BaseClass and remove this redefinition |
| 23 | +JSON_ITEM = Union[str, int, float, bool, Dict[str, "JSON_ITEM"], List["JSON_ITEM"]] |
| 24 | + |
20 | 25 |
|
21 | 26 | class MetadataRevisions: |
22 | 27 | def __init__(self, context, link): |
@@ -229,7 +234,7 @@ def item(self): |
229 | 234 | return self._item |
230 | 235 |
|
231 | 236 | @property |
232 | | - def metadata(self): |
| 237 | + def metadata(self) -> DictView[str, JSON_ITEM]: |
233 | 238 | "Metadata about this data source." |
234 | 239 | # Ensure this is immutable (at the top level) to help the user avoid |
235 | 240 | # getting the wrong impression that editing this would update anything |
@@ -262,12 +267,12 @@ def metadata_copy(self): |
262 | 267 | ] # returning as list of mutable items |
263 | 268 |
|
264 | 269 | @property |
265 | | - def specs(self): |
| 270 | + def specs(self) -> ListView[Spec]: |
266 | 271 | "List of specifications describing the structure of the metadata and/or data." |
267 | 272 | return ListView([Spec(**spec) for spec in self._item["attributes"]["specs"]]) |
268 | 273 |
|
269 | 274 | @property |
270 | | - def access_blob(self): |
| 275 | + def access_blob(self) -> DictView[str, JSON_ITEM]: |
271 | 276 | "Authorization information about this node, in blob form" |
272 | 277 | access_blob = self._item["attributes"]["access_blob"] |
273 | 278 | if access_blob is None: |
|
0 commit comments