1"""Helpers for use with type annotation. 2 3Use the empty classes in this module when annotating the types of Pyrsistent 4objects, instead of using the actual collection class. 5 6For example, 7 8 from pyrsistent import pvector 9 from pyrsistent.typing import PVector 10 11 myvector: PVector[str] = pvector(['a', 'b', 'c']) 12 13""" 14 15try: 16 from typing import Container 17 from typing import Hashable 18 from typing import Generic 19 from typing import Iterable 20 from typing import Mapping 21 from typing import Sequence 22 from typing import Sized 23 from typing import TypeVar 24 25 __all__ = ['CheckedPSet', 'CheckedPVector', 'PBag', 'PDeque', 'PList', 'PMap', 'PSet', 'PVector'] 26 27 T = TypeVar('T') 28 KT = TypeVar('KT') 29 VT = TypeVar('VT') 30 31 # PSet.add and PSet.discard have different type signatures than that of Set. 32 class CheckedPSet(Generic[T], Hashable): 33 pass 34 35 class CheckedPVector(Sequence[T], Hashable): 36 pass 37 38 class PBag(Container[T], Iterable[T], Sized, Hashable): 39 pass 40 41 class PDeque(Sequence[T], Hashable): 42 pass 43 44 class PList(Sequence[T], Hashable): 45 pass 46 47 class PMap(Mapping[KT, VT], Hashable): 48 pass 49 50 # PSet.add and PSet.discard have different type signatures than that of Set. 51 class PSet(Generic[T], Hashable): 52 pass 53 54 class PVector(Sequence[T], Hashable): 55 pass 56except ImportError: 57 pass 58