flavored

Sentinel values “indexed” by hashable values of a given type.

final class pythonic_fp.gadgets.sentinels.flavored.Sentinel

Bases: Generic

Sentinel

Sentinel values labeled by different (hashable) flavors.

Note

  • Useful for union types.

  • A flavored Sentinel value always equals itself and never equals anything else, especially other flavored sentinel values.

static __new__(cls, flavor: H) Sentinel[H]

new

param flavor:

Hashable value determining which flavored Sentinel to return.

returns:

The Sentinel(flavor) singleton instance.

__init__(flavor: H) None

init

param flavor:

Hashable value to initially cache the flavor

type flavor:

H: Hashable

__repr__() str

repr string

Construct string ‘Sentinel(flavor)’ where the flavor is displayed with repr().

returns:

A string to reproduce the flavored sentinel.

__str__() str

user string

Construct string ‘Sentinel(flavor)’ where the flavor is displayed with str().

returns:

A string meaningful to an end user.

flavor() H

get flavor

returns:

The sentinel’s flavor.

__annotate_func__()

The type of the None singleton.