|
1 | | -import collections.abc |
2 | 1 | import copy |
3 | 2 | import itertools |
4 | 3 | import operator |
5 | | -import sys |
6 | 4 | from collections import Counter |
7 | 5 | from datetime import datetime, timedelta, timezone |
8 | 6 | from typing import ( |
|
20 | 18 | if TYPE_CHECKING: |
21 | 19 | from fastapi import APIRouter |
22 | 20 |
|
| 21 | +from collections.abc import Iterable, Mapping |
| 22 | + |
23 | 23 | from ..iterviews import ItemsView, KeysView, ValuesView |
24 | 24 | from ..queries import ( |
25 | 25 | Comparison, |
|
43 | 43 | from .protocols import AccessPolicy, AnyAdapter |
44 | 44 | from .utils import IndexersMixin |
45 | 45 |
|
46 | | -if sys.version_info < (3, 9): |
47 | | - from typing_extensions import Mapping |
48 | | - |
49 | | - MappingType = Mapping |
50 | | -else: |
51 | | - import collections |
52 | | - |
53 | | - MappingType = collections.abc.Mapping |
54 | | - |
55 | 46 |
|
56 | | -class MapAdapter(MappingType[str, AnyAdapter], IndexersMixin): |
| 47 | +class MapAdapter(Mapping[str, AnyAdapter], IndexersMixin): |
57 | 48 | """ |
58 | 49 | Adapt any mapping (dictionary-like object) to Tiled. |
59 | 50 | """ |
@@ -537,7 +528,7 @@ def walk_string_values(tree: MapAdapter, node: Optional[Any] = None) -> Iterator |
537 | 528 | elif hasattr(value, "items"): |
538 | 529 | for k, v in value.items(): |
539 | 530 | yield from walk_string_values(value, k) |
540 | | - elif isinstance(value, collections.abc.Iterable): |
| 531 | + elif isinstance(value, Iterable): |
541 | 532 | for item in value: |
542 | 533 | if isinstance(item, str): |
543 | 534 | yield item |
@@ -706,7 +697,7 @@ def contains(query: Any, tree: MapAdapter) -> MapAdapter: |
706 | 697 | matches = {} |
707 | 698 | for key, value, term in iter_child_metadata(query.key, tree): |
708 | 699 | if ( |
709 | | - isinstance(term, collections.abc.Iterable) |
| 700 | + isinstance(term, Iterable) |
710 | 701 | and (not isinstance(term, str)) |
711 | 702 | and (query.value in term) |
712 | 703 | ): |
|
0 commit comments