Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing attributes for docutils.io #8716

Merged
merged 4 commits into from Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion stubs/docutils/@tests/stubtest_allowlist.txt
Expand Up @@ -4,7 +4,6 @@ docutils.frontend.ConfigParser.read
docutils.frontend.OptionParser.__getattr__
docutils.io.FileOutput.__getattr__
docutils.io.FileOutput.__init__
docutils.io.Input.__getattr__
docutils.io.Input.__init__
docutils.languages.LanguageImporter.__getattr__
docutils.nodes.Element.__getattr__
Expand Down
25 changes: 22 additions & 3 deletions stubs/docutils/docutils/io.pyi
@@ -1,5 +1,6 @@
from _typeshed import OpenBinaryModeReading, OpenBinaryModeWriting, OpenTextModeReading, OpenTextModeWriting
from typing import Any, ClassVar
from _typeshed import OpenBinaryModeReading, OpenBinaryModeWriting, OpenTextModeReading, OpenTextModeWriting, SupportsWrite
from typing import Any, ClassVar, Pattern
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
from typing_extensions import Literal

from docutils import TransformSpec

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

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

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

class Output(TransformSpec):
component_type: ClassVar[str]
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: str | SupportsWrite[str] | SupportsWrite[bytes] | Literal[False] | None = ...,
encoding: str | None = ...,
encoding_errors: str = ...,
decoding_errors: str = ...,
) -> None: ...
def write(self, data: str | bytes | Exception) -> 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