typeddfs.frozen_types

Hashable and ordered collections.

Module Contents

class typeddfs.frozen_types.FrozeDict(dct: Mapping[K, V])

An immutable dictionary/mapping. Hashable and ordered.

EMPTY :FrozeDict
__contains__(self, item: K) bool
__eq__(self, other: FrozeDict[K, V]) bool

Return self==value.

__getitem__(self, item: K) T
__hash__(self) int

Return hash(self).

__iter__(self)
__len__(self) int
__lt__(self, other: Mapping[K, V])

Compares this dict to another, with partial ordering.

The algorithm is:
  1. Sort self and other by keys

  2. If sorted_self < sorted_other, return False

  3. If the reverse is true (sorted_other < sorted_self), return True

  4. (The keys are now known to be the same.) For each key, in order: If self[key] < other[key], return True

  5. Return False

__make_other(self, other: Union[FrozeDict[K, V], Mapping[K, V]]) Dict[K, V]
__repr__(self) str

Return repr(self).

__str__(self) str

Return str(self).

get(self, key: K, default: Optional[V] = None) Optional[V]

D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.

property is_empty(self) bool
items(self) AbstractSet[tuple[K, V]]

D.items() -> a set-like object providing a view on D’s items

keys(self) AbstractSet[K]

D.keys() -> a set-like object providing a view on D’s keys

property length(self) int
req(self, key: K, default: Optional[V] = None) V

Returns the value corresponding to key. Short for β€œrequire”. Falls back to default if default is not None and key is not in this dict.

Raise: KeyError: If key is not in this dict and default is None

to_dict(self) MutableMapping[K, V]
values(self) ValuesView[V]

D.values() -> an object providing a view on D’s values

class typeddfs.frozen_types.FrozeList(lst: Sequence[T])

An immutable list. Hashable and ordered.

EMPTY :FrozeList
__eq__(self, other: Union[FrozeList[T], Sequence[T]]) bool

Return self==value.

__getitem__(self, item: int)
__hash__(self) int

Return hash(self).

__iter__(self) Iterator[T]
__len__(self) int
__lt__(self, other: Union[FrozeList[T], Sequence[T]])

Return self<value.

__make_other(self, other: Union[FrozeList[T], Sequence[T]]) List[T]
__repr__(self) str

Return repr(self).

__str__(self) str

Return str(self).

get(self, item: T, default: Optional[T] = None) Optional[T]
property is_empty(self) bool
property length(self) int
req(self, item: T, default: Optional[T] = None) T

Returns the requested list item, falling back to a default. Short for β€œrequire”.

Raises

KeyError – If item is not in this list and default is None

to_list(self) List[T]
class typeddfs.frozen_types.FrozeSet(lst: AbstractSet[T])

An immutable set. Hashable and ordered. This is almost identical to typing.FrozenSet, but it’s behavior was made equivalent to those of FrozeDict and FrozeList.

EMPTY :FrozeSet
__contains__(self, x: T) bool
__eq__(self, other: FrozeSet[T]) bool

Return self==value.

__getitem__(self, item: T) T
__hash__(self) int

Return hash(self).

__iter__(self) Iterator[T]
__len__(self) int
__lt__(self, other: Union[FrozeSet[T], AbstractSet[T]])

Compares self and other for partial ordering. Sorts self and other, then compares the two sorted sets.

Approximately::

return list(sorted(self)) < list(sorted(other))

__make_other(self, other: Union[FrozeSet[T], AbstractSet[T]]) Set[T]
__repr__(self) str

Return repr(self).

__str__(self) str

Return str(self).

get(self, item: T, default: Optional[T] = None) Optional[T]
property is_empty(self) bool
property length(self) int
req(self, item: T, default: Optional[T] = None) T

Returns item if it is in this set. Short for β€œrequire”. Falls back to default if default is not None.

Raises

KeyError – If item is not in this set and default is None

to_frozenset(self) AbstractSet[T]
to_set(self) AbstractSet[T]