jgdv._abstract.protocols.stdlib

An Adaptation of typeshed’s protocol’s of the stdlib.

Protocols

Buffer_p

Base class for protocol classes.

Callable_p

Base class for protocol classes.

Collection_p

Base class for protocol classes.

Container_p

Base class for protocol classes.

Generator_p

Base class for protocol classes.

Hashable_p

Base class for protocol classes.

ItemsView_p

Base class for protocol classes.

Iterable_p

Base class for protocol classes.

Iterator_p

Base class for protocol classes.

KeysView_p

Base class for protocol classes.

MappingView_p

Base class for protocol classes.

Mapping_p

A Mapping_p is a generic container for associating key/value

MutableMapping_p

A MutableMapping is a generic container for associating

MutableSequence_p

All the operations on a read-write sequence.

MutableSet_p

A mutable set is a finite, iterable container.

Reversible_p

Base class for protocol classes.

Sequence_p

All the operations on a read-only sequence.

Set_p

A set is a finite, iterable container.

Sized_p

Base class for protocol classes.

ValuesView_p

Base class for protocol classes.

Module Contents

class jgdv._abstract.protocols.stdlib.Buffer_p[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
class jgdv._abstract.protocols.stdlib.Callable_p[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
class jgdv._abstract.protocols.stdlib.Collection_p[source]

Bases: Sized_p, Iterable_p, Container_p, Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
class jgdv._abstract.protocols.stdlib.Container_p[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
class jgdv._abstract.protocols.stdlib.Generator_p[source]

Bases: Iterator_p, Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
close() <Unknown>[source]
Return type:

None

send(value) <Unknown>[source]
Parameters:

value (Any)

Return type:

Any

throw(typ, val=None, tb=None) <Unknown>[source]
Parameters:
  • typ (Any)

  • val (jgdv.Maybe)

  • tb (jgdv.Maybe)

Return type:

Any

class jgdv._abstract.protocols.stdlib.Hashable_p[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
class jgdv._abstract.protocols.stdlib.ItemsView_p(mapping)[source]

Bases: MappingView_p, Set_p, Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
Parameters:

mapping (Mapping_p)

classmethod _from_iterable(it) <Unknown>[source]
Parameters:

it (Iterable_p)

Return type:

ItemsView_p

class jgdv._abstract.protocols.stdlib.Iterable_p[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
class jgdv._abstract.protocols.stdlib.Iterator_p[source]

Bases: Iterable_p, Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
class jgdv._abstract.protocols.stdlib.KeysView_p(mapping)[source]

Bases: MappingView_p, Set_p, Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
Parameters:

mapping (Mapping_p)

classmethod _from_iterable(it) <Unknown>[source]
Parameters:

it (Iterable_p[K])

Return type:

KeysView_p[K]

class jgdv._abstract.protocols.stdlib.MappingView_p(mapping)[source]

Bases: Sized_p, Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
Parameters:

mapping (Mapping_p)

class jgdv._abstract.protocols.stdlib.Mapping_p[source]

Bases: Collection_p, Protocol

A Mapping_p is a generic container for associating key/value pairs.

This class provides concrete generic implementations of all methods except for __getitem__, __iter__, and __len__.

get(key, default=None) <Unknown>[source]
Parameters:
  • key (K)

  • default (jgdv.Maybe[Any])

Return type:

V | Mapping_p.get.D

items() <Unknown>[source]
Return type:

ItemsView_p

keys() <Unknown>[source]
Return type:

KeysView_p

values() <Unknown>[source]
Return type:

ValuesView_p

class jgdv._abstract.protocols.stdlib.MutableMapping_p[source]

Bases: Mapping_p[MutableMapping_p.K, MutableMapping_p.V], Protocol

A MutableMapping is a generic container for associating key/value pairs.

This class provides concrete generic implementations of all methods except for __getitem__, __setitem__, __delitem__, __iter__, and __len__.

clear() <Unknown>[source]
Return type:

None

pop(key, default=None) <Unknown>[source]
Parameters:
  • key (K)

  • default (jgdv.Maybe[MutableMapping_p.pop.D])

Return type:

MutableMapping_p.pop.D

popitem() <Unknown>[source]
Return type:

V

setdefault(key, default=None) <Unknown>[source]
Parameters:
  • key (K)

  • default (jgdv.Maybe[MutableMapping_p.setdefault.D])

Return type:

V | MutableMapping_p.setdefault.D

update(other=(), /, **kwds) <Unknown>[source]
Parameters:
Return type:

None

class jgdv._abstract.protocols.stdlib.MutableSequence_p[source]

Bases: Sequence_p, Protocol

All the operations on a read-write sequence.

Concrete subclasses must provide __new__ or __init__, __getitem__, __setitem__, __delitem__, __len__, and insert().

append(value) <Unknown>[source]
Parameters:

value (V)

Return type:

None

clear() <Unknown>[source]
Return type:

None

extend(values) <Unknown>[source]
Parameters:

values (Iterable_p[V])

Return type:

None

insert(index, value) <Unknown>[source]
Parameters:
  • index (int)

  • value (V)

Return type:

None

pop(index=-1) <Unknown>[source]
Parameters:

index (int)

Return type:

V

remove(value) <Unknown>[source]
Parameters:

value (V)

Return type:

None

reverse() <Unknown>[source]
Return type:

None

class jgdv._abstract.protocols.stdlib.MutableSet_p[source]

Bases: Set_p[MutableSet_p.V], Protocol

A mutable set is a finite, iterable container.

This class provides concrete generic implementations of all methods except for __contains__, __iter__, __len__, add(), and discard().

To override the comparisons (presumably for speed, as the semantics are fixed), all you have to do is redefine __le__ and then the other operations will automatically follow suit.

add(value) <Unknown>[source]
Parameters:

value (V)

Return type:

Self

clear() <Unknown>[source]
Return type:

None

discard(value) <Unknown>[source]
Parameters:

value (V)

Return type:

None

pop() <Unknown>[source]
Return type:

V

remove(value) <Unknown>[source]
Parameters:

value (V)

Return type:

None

class jgdv._abstract.protocols.stdlib.Reversible_p[source]

Bases: Iterable_p, Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
class jgdv._abstract.protocols.stdlib.Sequence_p[source]

Bases: Reversible_p, Collection_p, Protocol

All the operations on a read-only sequence.

Concrete subclasses must override __new__ or __init__, __getitem__, and __len__.

count(value) <Unknown>[source]
Parameters:

value (V)

Return type:

int

index(value, start=0, stop=None) <Unknown>[source]
Parameters:
  • value (V)

  • start (int)

  • stop (jgdv.Maybe[int])

Return type:

int

class jgdv._abstract.protocols.stdlib.Set_p[source]

Bases: Collection_p, Protocol

A set is a finite, iterable container.

This class provides concrete generic implementations of all methods except for __contains__, __iter__ and __len__.

To override the comparisons (presumably for speed, as the semantics are fixed), redefine __le__ and __ge__, then the other operations will automatically follow suit.

classmethod _from_iterable(it) <Unknown>[source]
Parameters:

it (Iterable_p[V])

Return type:

Set_p[V]

_hash() <Unknown>[source]
Return type:

int

isdisjoint(other) <Unknown>[source]
Parameters:

other (Self)

Return type:

bool

class jgdv._abstract.protocols.stdlib.Sized_p[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
class jgdv._abstract.protocols.stdlib.ValuesView_p(mapping)[source]

Bases: MappingView_p, Collection_p, Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
Parameters:

mapping (Mapping_p)