Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions stubs/docutils/docutils/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ from _typeshed import (
OpenBinaryModeWriting,
OpenTextModeReading,
OpenTextModeWriting,
StrPath,
SupportsWrite,
Unused,
)
from re import Pattern
from typing import IO, Any, ClassVar, Final, Generic, Literal, TextIO, TypeVar
from typing import IO, Any, BinaryIO, ClassVar, Final, Generic, Literal, TextIO, TypeVar
from typing_extensions import deprecated

from docutils import TransformSpec, nodes
Expand Down Expand Up @@ -49,21 +50,25 @@ class Input(TransformSpec, Generic[_S]):
class Output(TransformSpec):
component_type: ClassVar[str]
default_destination_path: ClassVar[str | None]
encoding: Incomplete
error_handler: Incomplete
encoding: str | None
error_handler: str
destination: Incomplete
destination_path: Incomplete
destination_path: StrPath | None
def __init__(
self, destination=None, destination_path=None, encoding: str | None = None, error_handler: str = "strict"
self,
destination=None,
destination_path: StrPath | None = None,
encoding: str | None = None,
error_handler: str | None = "strict",
) -> None: ...
def write(self, data: str) -> Any: ... # returns bytes or str
def encode(self, data: str) -> Any: ... # returns bytes or str

class ErrorOutput:
destination: Incomplete
encoding: Incomplete
encoding_errors: Incomplete
decoding_errors: Incomplete
destination: TextIO | BinaryIO | Literal[False]
encoding: str
encoding_errors: str
decoding_errors: str
def __init__(
self,
destination: str | SupportsWrite[str] | SupportsWrite[bytes] | Literal[False] | None = None,
Expand All @@ -80,9 +85,9 @@ class FileInput(Input[IO[str]]):
def __init__(
self,
source=None,
source_path=None,
source_path: StrPath | None = None,
encoding: str | None = "utf-8",
error_handler: str = "strict",
error_handler: str | None = "strict",
autoclose: bool = True,
mode: OpenTextModeReading | OpenBinaryModeReading = "r",
) -> None: ...
Expand All @@ -94,34 +99,32 @@ class FileOutput(Output):
default_destination_path: ClassVar[str]
mode: ClassVar[OpenTextModeWriting | OpenBinaryModeWriting]
opened: bool
autoclose: Incomplete
destination: Incomplete
destination_path: Incomplete
autoclose: bool
def __init__(
self,
destination=None,
destination_path=None,
encoding=None,
error_handler: str = "strict",
destination_path: StrPath | None = None,
encoding: str | None = None,
error_handler: str | None = "strict",
autoclose: bool = True,
handle_io_errors=None,
mode=None,
handle_io_errors: None = None,
mode: OpenTextModeWriting | OpenBinaryModeWriting | None = None,
) -> None: ...
def open(self) -> None: ...
def write(self, data): ...
def write(self, data: str | bytes) -> str | bytes: ...
def close(self) -> None: ...

@deprecated("The `BinaryFileOutput` is deprecated by `FileOutput` and will be removed in Docutils 0.24.")
class BinaryFileOutput(FileOutput): ...

class StringInput(Input[str]):
default_source_path: ClassVar[str]
def read(self): ...
def read(self) -> str: ...

class StringOutput(Output):
default_destination_path: ClassVar[str]
destination: str | bytes # only defined after call to write()
def write(self, data): ...
def write(self, data: str | bytes) -> str | bytes: ...

class NullInput(Input[Any]):
default_source_path: ClassVar[str]
Expand Down