.. _jgdv._abstract.protocols.str: ============================ jgdv._abstract.protocols.str ============================ .. py:module:: jgdv._abstract.protocols.str .. autoapi-nested-parse:: Adapated from typeshed, this is a full protocol of the stdlib `str`. Type Aliases ------------ .. autoapisummary:: jgdv._abstract.protocols.str.ReadableBuffer jgdv._abstract.protocols.str.SupportsIndex jgdv._abstract.protocols.str._FormatMapMapping jgdv._abstract.protocols.str._TranslateTable Protocols --------- .. autoapisummary:: jgdv._abstract.protocols.str.String_p Module Contents =============== .. py:data:: ReadableBuffer :type: TypeAlias :value: Any .. py:data:: SupportsIndex :type: TypeAlias :value: Any .. py:data:: _FormatMapMapping :type: TypeAlias :value: Any .. py:data:: _TranslateTable :type: TypeAlias :value: Any .. _jgdv._abstract.protocols.str.String_p: .. py:class:: String_p Bases: :py:obj:`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: ... .. py:method:: capitalize() -> .. py:method:: casefold() -> .. py:method:: center(width, fillchar = ' ', /) -> .. py:method:: count(sub, start = ..., end = ..., /) -> .. py:method:: encode(encoding = 'utf-8', errors = 'strict') -> .. py:method:: endswith(suffix, start = ..., end = ...) -> .. py:method:: expandtabs(tabsize = 8) -> .. py:method:: find(sub, start = ..., end = ..., /) -> .. py:method:: format(*args, **kwargs) -> .. py:method:: format_map(mapping, /) -> .. py:method:: index(sub, start = ..., end = ..., /) -> .. py:method:: isalnum() -> .. py:method:: isalpha() -> .. py:method:: isascii() -> .. py:method:: isdecimal() -> .. py:method:: isdigit() -> .. py:method:: isidentifier() -> .. py:method:: islower() -> .. py:method:: isnumeric() -> .. py:method:: isprintable() -> .. py:method:: isspace() -> .. py:method:: istitle() -> .. py:method:: isupper() -> .. py:method:: join(iterable, /) -> .. py:method:: ljust(width, fillchar = ' ', /) -> .. py:method:: lower() -> .. py:method:: lstrip(chars = None, /) -> .. py:method:: maketrans(x: dict[str | int, String_p.maketrans._T], /) -> dict[int, String_p.maketrans._T] maketrans(x: str, y: str, /) -> dict[int, int] maketrans(x: str, y: str, z: str, /) -> dict[int, jgdv.Maybe[int]] :staticmethod: .. py:method:: partition(sep, /) -> .. py:method:: removeprefix(prefix, /) -> .. py:method:: removesuffix(suffix, /) -> .. py:method:: replace(old, new, /, count = -1) -> .. py:method:: rfind(sub, start = ..., end = ..., /) -> .. py:method:: rindex(sub, start = ..., end = ..., /) -> .. py:method:: rjust(width, fillchar = ' ', /) -> .. py:method:: rpartition(sep, /) -> .. py:method:: rsplit(sep = None, maxsplit = -1) -> .. py:method:: rstrip(chars = None, /) -> .. py:method:: split(sep = None, maxsplit = -1) -> .. py:method:: splitlines(keepends = False) -> .. py:method:: startswith(prefix, start = ..., end = ..., /) -> .. py:method:: strip(chars = None, /) -> .. py:method:: swapcase() -> .. py:method:: title() -> .. py:method:: translate(table, /) -> .. py:method:: upper() -> .. py:method:: zfill(width, /) ->