jgdv._abstract.protocols.stdlib
An Adaptation of typeshed’s protocol’s of the stdlib.
Protocols
Base class for protocol classes. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
A Mapping_p is a generic container for associating key/value |
|
A MutableMapping is a generic container for associating |
|
All the operations on a read-write sequence. |
|
A mutable set is a finite, iterable container. |
|
Base class for protocol classes. |
|
All the operations on a read-only sequence. |
|
A set is a finite, iterable container. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
Module Contents
- class jgdv._abstract.protocols.stdlib.Buffer_p[source]
Bases:
ProtocolBase 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:
ProtocolBase 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,ProtocolBase 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:
ProtocolBase 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,ProtocolBase 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.Hashable_p[source]
Bases:
ProtocolBase 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,ProtocolBase 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:
- class jgdv._abstract.protocols.stdlib.Iterable_p[source]
Bases:
ProtocolBase 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,ProtocolBase 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,ProtocolBase 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,ProtocolBase 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,ProtocolA 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
- class jgdv._abstract.protocols.stdlib.MutableMapping_p[source]
Bases:
Mapping_p[MutableMapping_p.K,MutableMapping_p.V],ProtocolA 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__.
- pop(key, default=None) <Unknown>[source]
- Parameters:
key (K)
default (jgdv.Maybe[MutableMapping_p.pop.D])
- Return type:
MutableMapping_p.pop.D
- 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:
other (Iterable_p)
kwds (Any)
- Return type:
None
- class jgdv._abstract.protocols.stdlib.MutableSequence_p[source]
Bases:
Sequence_p,ProtocolAll the operations on a read-write sequence.
Concrete subclasses must provide __new__ or __init__, __getitem__, __setitem__, __delitem__, __len__, and insert().
- extend(values) <Unknown>[source]
- Parameters:
values (Iterable_p[V])
- Return type:
None
- class jgdv._abstract.protocols.stdlib.MutableSet_p[source]
Bases:
Set_p[MutableSet_p.V],ProtocolA 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.
- class jgdv._abstract.protocols.stdlib.Reversible_p[source]
Bases:
Iterable_p,ProtocolBase 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,ProtocolAll the operations on a read-only sequence.
Concrete subclasses must override __new__ or __init__, __getitem__, and __len__.
- class jgdv._abstract.protocols.stdlib.Set_p[source]
Bases:
Collection_p,ProtocolA 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]
- class jgdv._abstract.protocols.stdlib.Sized_p[source]
Bases:
ProtocolBase 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,ProtocolBase 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)