Coverage for src / c41811 / config / _protocols.py: 100%
10 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-06 06:04 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-06 06:04 +0000
1# cython: language_level = 3 # noqa: ERA001
4from typing import Protocol
5from typing import TypeVar
6from typing import overload
8_T_co = TypeVar("_T_co", covariant=True)
9_T_contra = TypeVar("_T_contra", contravariant=True)
12class SupportsWrite(Protocol[_T_contra]):
13 def write(self, __s: _T_contra) -> object: ...
16class SupportsReadAndReadline(Protocol[_T_co]):
17 def read(self, __length: int = ...) -> _T_co: ...
19 @overload
20 def readline(self) -> _T_co: ...
22 @overload
23 def readline(self, __length: int) -> _T_co: ...
25 def readline(self, __length: int = ...) -> _T_co: ...
28class Indexed(Protocol[_T_contra, _T_co]):
29 # noinspection GrazieInspection
30 """
31 可索引
33 .. versionchanged:: 0.2.0
34 重命名 ``SupportsIndex`` 为 ``Indexed``
35 """
37 def __getitem__(self, __index: _T_contra) -> _T_co: ...
40class MutableIndexed(Indexed[_T_contra, _T_co]):
41 # noinspection GrazieInspection
42 """
43 可变可索引
45 .. versionchanged:: 0.2.0
46 重命名 ``SupportsWriteIndex`` 为 ``MutableIndexed``
47 """
49 def __setitem__(self, __index: _T_contra, __value: _T_contra) -> None: ...
51 def __delitem__(self, __index: _T_contra) -> None: ...
54__all__ = (
55 "Indexed",
56 "MutableIndexed",
57 "SupportsReadAndReadline",
58 "SupportsWrite",
59)