1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
from __future__ import annotations
from collections import abc, defaultdict, deque
from collections.abc import Iterable, Mapping, Sequence
from random import Random
from typing import (
Union,
)
try:
from types import UnionType
except ImportError:
UnionType = Union # type: ignore[misc,assignment]
# Mapping of type annotations into concrete types.
TYPE_MAPPING = {
defaultdict: defaultdict,
deque: deque,
dict: dict,
frozenset: frozenset,
Iterable: list,
list: list,
Mapping: dict,
Sequence: list,
set: set,
tuple: tuple,
abc.Iterable: list,
abc.Mapping: dict,
abc.Sequence: list,
abc.Set: set,
UnionType: Union,
}
DEFAULT_RANDOM = Random()
RANDOMIZE_COLLECTION_LENGTH = False
MIN_COLLECTION_LENGTH = 0
MAX_COLLECTION_LENGTH = 5
|