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:
...
-
capitalize() → <Unknown>[source]
- Return type:
str
-
casefold() → <Unknown>[source]
- Return type:
str
-
center(width, fillchar=' ', /) → <Unknown>[source]
- Parameters:
width (SupportsIndex)
fillchar (str)
- Return type:
str
-
count(sub, start=..., end=..., /) → <Unknown>[source]
- Parameters:
-
- Return type:
int
-
encode(
- encoding='utf-8',
- errors='strict',
) → <Unknown>[source]
- Parameters:
-
- Return type:
bytes
-
endswith(
- suffix,
- start=...,
- end=...,
) → <Unknown>[source]
- Parameters:
suffix (str | tuple[str, Ellipsis])
start (jgdv.Maybe[SupportsIndex])
end (jgdv.Maybe[SupportsIndex])
- Return type:
bool
-
expandtabs(tabsize=8) → <Unknown>[source]
- Parameters:
tabsize (SupportsIndex)
- Return type:
str
-
find(sub, start=..., end=..., /) → <Unknown>[source]
- Parameters:
-
- Return type:
int
-
format(*args, **kwargs) → <Unknown>[source]
- Parameters:
-
- Return type:
str
-
format_map(mapping, /) → <Unknown>[source]
- Parameters:
mapping (_FormatMapMapping)
- Return type:
str
-
index(sub, start=..., end=..., /) → <Unknown>[source]
- Parameters:
-
- Return type:
int
-
isalnum() → <Unknown>[source]
- Return type:
bool
-
isalpha() → <Unknown>[source]
- Return type:
bool
-
isascii() → <Unknown>[source]
- Return type:
bool
-
isdecimal() → <Unknown>[source]
- Return type:
bool
-
isdigit() → <Unknown>[source]
- Return type:
bool
-
isidentifier() → <Unknown>[source]
- Return type:
bool
-
islower() → <Unknown>[source]
- Return type:
bool
-
isnumeric() → <Unknown>[source]
- Return type:
bool
-
isprintable() → <Unknown>[source]
- Return type:
bool
-
isspace() → <Unknown>[source]
- Return type:
bool
-
istitle() → <Unknown>[source]
- Return type:
bool
-
isupper() → <Unknown>[source]
- Return type:
bool
-
join(iterable, /) → <Unknown>[source]
- Parameters:
iterable (collections.abc.Iterable[str])
- Return type:
str
-
ljust(width, fillchar=' ', /) → <Unknown>[source]
- Parameters:
width (SupportsIndex)
fillchar (str)
- Return type:
str
-
lower() → <Unknown>[source]
- Return type:
str
-
lstrip(chars=None, /) → <Unknown>[source]
- Parameters:
chars (jgdv.Maybe[str])
- Return type:
str
-
static maketrans(
- x: dict[str | int, String_p.maketrans._T],
- /,
) → dict[int, String_p.maketrans._T][source]
-
static maketrans(x: str, y: str, /) → dict[int, int]
-
static maketrans(
- x: str,
- y: str,
- z: str,
- /,
) → dict[int, jgdv.Maybe[int]]
-
partition(sep, /) → <Unknown>[source]
- Parameters:
sep (str)
- Return type:
tuple[str, str, str]
-
removeprefix(prefix, /) → <Unknown>[source]
- Parameters:
prefix (str)
- Return type:
str
-
removesuffix(suffix, /) → <Unknown>[source]
- Parameters:
suffix (str)
- Return type:
str
-
replace(old, new, /, count=-1) → <Unknown>[source]
- Parameters:
old (LiteralString)
new (LiteralString)
count (SupportsIndex)
- Return type:
LiteralString
-
rfind(sub, start=..., end=..., /) → <Unknown>[source]
- Parameters:
-
- Return type:
int
-
rindex(
- sub,
- start=...,
- end=...,
- /,
) → <Unknown>[source]
- Parameters:
-
- Return type:
int
-
rjust(width, fillchar=' ', /) → <Unknown>[source]
- Parameters:
width (SupportsIndex)
fillchar (str)
- Return type:
str
-
rpartition(sep, /) → <Unknown>[source]
- Parameters:
sep (str)
- Return type:
tuple[str, str, str]
-
rsplit(sep=None, maxsplit=-1) → <Unknown>[source]
- Parameters:
sep (jgdv.Maybe[str])
maxsplit (SupportsIndex)
- Return type:
list[str]
-
rstrip(chars=None, /) → <Unknown>[source]
- Parameters:
chars (jgdv.Maybe[str])
- Return type:
str
-
split(sep=None, maxsplit=-1) → <Unknown>[source]
- Parameters:
sep (jgdv.Maybe[str])
maxsplit (SupportsIndex)
- Return type:
list[str]
-
splitlines(keepends=False) → <Unknown>[source]
- Parameters:
keepends (bool)
- Return type:
list[str]
-
startswith(
- prefix,
- start=...,
- end=...,
- /,
) → <Unknown>[source]
- Parameters:
prefix (str | tuple[str, Ellipsis])
start (jgdv.Maybe[SupportsIndex])
end (jgdv.Maybe[SupportsIndex])
- Return type:
bool
-
strip(chars=None, /) → <Unknown>[source]
- Parameters:
chars (jgdv.Maybe[str])
- Return type:
str
-
swapcase() → <Unknown>[source]
- Return type:
str
-
title() → <Unknown>[source]
- Return type:
str
-
translate(table, /) → <Unknown>[source]
- Parameters:
table (_TranslateTable)
- Return type:
str
-
upper() → <Unknown>[source]
- Return type:
str
-
zfill(width, /) → <Unknown>[source]
- Parameters:
width (SupportsIndex)
- Return type:
str