Skip to content

Commit b4d9105

Browse files
Add missing attributes for docutils.io (#8716)
Co-authored-by: Alex Waygood <[email protected]>
1 parent 4905074 commit b4d9105

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

stubs/docutils/@tests/stubtest_allowlist.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ docutils.frontend.ConfigParser.read
44
docutils.frontend.OptionParser.__getattr__
55
docutils.io.FileOutput.__getattr__
66
docutils.io.FileOutput.__init__
7-
docutils.io.Input.__getattr__
87
docutils.io.Input.__init__
98
docutils.languages.LanguageImporter.__getattr__
109
docutils.nodes.Element.__getattr__

stubs/docutils/docutils/io.pyi

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from _typeshed import OpenBinaryModeReading, OpenBinaryModeWriting, OpenTextModeReading, OpenTextModeWriting
1+
from _typeshed import OpenBinaryModeReading, OpenBinaryModeWriting, OpenTextModeReading, OpenTextModeWriting, SupportsWrite
2+
from re import Pattern
23
from typing import Any, ClassVar
4+
from typing_extensions import Literal
35

46
from docutils import TransformSpec
57

@@ -9,12 +11,17 @@ class InputError(IOError): ...
911
class OutputError(IOError): ...
1012

1113
def check_encoding(stream: Any, encoding: str) -> bool | None: ...
14+
def error_string(err: BaseException) -> str: ...
1215

1316
class Input(TransformSpec):
1417
component_type: ClassVar[str]
1518
default_source_path: ClassVar[str | None]
1619
def read(self) -> Any: ...
17-
def __getattr__(self, name: str) -> Any: ... # incomplete
20+
def decode(self, data: str | bytes) -> str: ...
21+
coding_slug: ClassVar[Pattern[bytes]]
22+
byte_order_marks: ClassVar[tuple[tuple[bytes, str], ...]]
23+
def determine_encoding_from_data(self, data: str | bytes) -> str | None: ...
24+
def isatty(self) -> bool: ...
1825

1926
class Output(TransformSpec):
2027
component_type: ClassVar[str]
@@ -29,6 +36,18 @@ class Output(TransformSpec):
2936
def write(self, data: str) -> Any: ... # returns bytes or str
3037
def encode(self, data: str) -> Any: ... # returns bytes or str
3138

39+
class ErrorOutput:
40+
def __init__(
41+
self,
42+
destination: str | SupportsWrite[str] | SupportsWrite[bytes] | Literal[False] | None = ...,
43+
encoding: str | None = ...,
44+
encoding_errors: str = ...,
45+
decoding_errors: str = ...,
46+
) -> None: ...
47+
def write(self, data: str | bytes | Exception) -> None: ...
48+
def close(self) -> None: ...
49+
def isatty(self) -> bool: ...
50+
3251
class FileInput(Input):
3352
def __init__(
3453
self,
@@ -39,6 +58,7 @@ class FileInput(Input):
3958
autoclose: bool = ...,
4059
mode: OpenTextModeReading | OpenBinaryModeReading = ...,
4160
) -> None: ...
61+
def read(self) -> str: ...
4262
def readlines(self) -> list[str]: ...
4363
def close(self) -> None: ...
4464

0 commit comments

Comments
 (0)