Skip to content

Commit

Permalink
Add missing attributes for docutils.io
Browse files Browse the repository at this point in the history
`error_string` and `ErrorOutput` were added in `v0.19`.
Fills out some missing pieces of `Input` and `FileInput` as well.
  • Loading branch information
amyreese committed Sep 9, 2022
1 parent 8a8db9c commit b9ad6ab
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion stubs/docutils/docutils/io.pyi
@@ -1,5 +1,5 @@
from _typeshed import OpenBinaryModeReading, OpenBinaryModeWriting, OpenTextModeReading, OpenTextModeWriting
from typing import Any, ClassVar
from typing import Any, AnyStr, ClassVar, Pattern

from docutils import TransformSpec

Expand All @@ -9,11 +9,17 @@ class InputError(IOError): ...
class OutputError(IOError): ...

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

class Input(TransformSpec):
component_type: ClassVar[str]
default_source_path: ClassVar[str | None]
def read(self) -> Any: ...
def decode(self, data: AnyStr) -> str: ...
coding_slug: ClassVar[Pattern[bytes]]
byte_order_marks: ClassVar[tuple[tuple[bytes, str], ...]]
def determine_encoding_from_data(self, data: AnyStr) -> str: ...
def isatty(self) -> bool: ...
def __getattr__(self, name: str) -> Any: ... # incomplete

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

class ErrorOutput:
def __init__(
self,
destination: Any | None = ...,
encoding: str | None = ...,
encoding_errors: str | None = ...,
decoding_errors: str | None = ...,
) -> None: ...
def write(self, data: AnyStr) -> None: ...
def close(self) -> None: ...
def isatty(self) -> bool: ...

class FileInput(Input):
def __init__(
self,
Expand All @@ -39,6 +57,7 @@ class FileInput(Input):
autoclose: bool = ...,
mode: OpenTextModeReading | OpenBinaryModeReading = ...,
) -> None: ...
def read(self) -> str: ...
def readlines(self) -> list[str]: ...
def close(self) -> None: ...

Expand Down

0 comments on commit b9ad6ab

Please sign in to comment.