1
- from _typeshed import OpenBinaryModeReading , OpenBinaryModeWriting , OpenTextModeReading , OpenTextModeWriting
1
+ from _typeshed import OpenBinaryModeReading , OpenBinaryModeWriting , OpenTextModeReading , OpenTextModeWriting , SupportsWrite
2
+ from re import Pattern
2
3
from typing import Any , ClassVar
4
+ from typing_extensions import Literal
3
5
4
6
from docutils import TransformSpec
5
7
@@ -9,12 +11,17 @@ class InputError(IOError): ...
9
11
class OutputError (IOError ): ...
10
12
11
13
def check_encoding (stream : Any , encoding : str ) -> bool | None : ...
14
+ def error_string (err : BaseException ) -> str : ...
12
15
13
16
class Input (TransformSpec ):
14
17
component_type : ClassVar [str ]
15
18
default_source_path : ClassVar [str | None ]
16
19
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 : ...
18
25
19
26
class Output (TransformSpec ):
20
27
component_type : ClassVar [str ]
@@ -29,6 +36,18 @@ class Output(TransformSpec):
29
36
def write (self , data : str ) -> Any : ... # returns bytes or str
30
37
def encode (self , data : str ) -> Any : ... # returns bytes or str
31
38
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
+
32
51
class FileInput (Input ):
33
52
def __init__ (
34
53
self ,
@@ -39,6 +58,7 @@ class FileInput(Input):
39
58
autoclose : bool = ...,
40
59
mode : OpenTextModeReading | OpenBinaryModeReading = ...,
41
60
) -> None : ...
61
+ def read (self ) -> str : ...
42
62
def readlines (self ) -> list [str ]: ...
43
63
def close (self ) -> None : ...
44
64
0 commit comments