Skip to content

Commit 044b563

Browse files
committed
Add missing attributes for docutils.io
`error_string` and `ErrorOutput` were added in `v0.19`. Fills out some missing pieces of `Input` and `FileInput` as well.
1 parent 8a8db9c commit 044b563

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

stubs/docutils/docutils/io.pyi

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed import OpenBinaryModeReading, OpenBinaryModeWriting, OpenTextModeReading, OpenTextModeWriting
2-
from typing import Any, ClassVar
2+
from typing import Any, AnyStr, ClassVar, Pattern, Tuple
33

44
from docutils import TransformSpec
55

@@ -9,11 +9,17 @@ class InputError(IOError): ...
99
class OutputError(IOError): ...
1010

1111
def check_encoding(stream: Any, encoding: str) -> bool | None: ...
12+
def error_string(err: str) -> str: ...
1213

1314
class Input(TransformSpec):
1415
component_type: ClassVar[str]
1516
default_source_path: ClassVar[str | None]
1617
def read(self) -> Any: ...
18+
def decode(self, data: AnyStr) -> str: ...
19+
coding_slug: ClassVar[Pattern[bytes]]
20+
byte_order_marks: ClassVar[tuple[tuple[bytes, str], ...]]
21+
def determine_encoding_from_data(self, data: AnyStr) -> str: ...
22+
def isatty(self) -> bool: ...
1723
def __getattr__(self, name: str) -> Any: ... # incomplete
1824

1925
class Output(TransformSpec):
@@ -29,6 +35,18 @@ class Output(TransformSpec):
2935
def write(self, data: str) -> Any: ... # returns bytes or str
3036
def encode(self, data: str) -> Any: ... # returns bytes or str
3137

38+
class ErrorOutput:
39+
def __init__(
40+
self,
41+
destination: Any | None = ...,
42+
encoding: str | None = ...,
43+
encoding_errors: str | None = ...,
44+
decoding_errors: str | None = ...,
45+
) -> None: ...
46+
def write(self, data: AnyStr) -> None: ...
47+
def close(self) -> None: ...
48+
def isatty(self) -> bool: ...
49+
3250
class FileInput(Input):
3351
def __init__(
3452
self,
@@ -39,6 +57,7 @@ class FileInput(Input):
3957
autoclose: bool = ...,
4058
mode: OpenTextModeReading | OpenBinaryModeReading = ...,
4159
) -> None: ...
60+
def read(self) -> str: ...
4261
def readlines(self) -> list[str]: ...
4362
def close(self) -> None: ...
4463

0 commit comments

Comments
 (0)