Skip to content

Commit 4d734e3

Browse files
authored
Add docutils definitions and (incomplete) modules (#5192)
1 parent d3b2caf commit 4d734e3

22 files changed

+281
-34
lines changed

stdlib/_typeshed/__init__.pyi

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,61 +70,53 @@ else:
7070
BytesPath = bytes
7171
AnyPath = Union[Text, bytes]
7272

73-
OpenTextMode = Literal[
74-
"r",
73+
OpenTextModeUpdating = Literal[
7574
"r+",
7675
"+r",
77-
"rt",
78-
"tr",
7976
"rt+",
8077
"r+t",
8178
"+rt",
8279
"tr+",
8380
"t+r",
8481
"+tr",
85-
"w",
8682
"w+",
8783
"+w",
88-
"wt",
89-
"tw",
9084
"wt+",
9185
"w+t",
9286
"+wt",
9387
"tw+",
9488
"t+w",
9589
"+tw",
96-
"a",
9790
"a+",
9891
"+a",
99-
"at",
100-
"ta",
10192
"at+",
10293
"a+t",
10394
"+at",
10495
"ta+",
10596
"t+a",
10697
"+ta",
107-
"x",
10898
"x+",
10999
"+x",
110-
"xt",
111-
"tx",
112100
"xt+",
113101
"x+t",
114102
"+xt",
115103
"tx+",
116104
"t+x",
117105
"+tx",
118-
"U",
119-
"rU",
120-
"Ur",
121-
"rtU",
122-
"rUt",
123-
"Urt",
124-
"trU",
125-
"tUr",
126-
"Utr",
127106
]
107+
OpenTextModeWriting = Literal[
108+
"w",
109+
"wt",
110+
"tw",
111+
"a",
112+
"at",
113+
"ta",
114+
"x",
115+
"xt",
116+
"tx",
117+
]
118+
OpenTextModeReading = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"]
119+
OpenTextMode = Union[OpenTextModeUpdating, OpenTextModeWriting, OpenTextModeReading]
128120
OpenBinaryModeUpdating = Literal[
129121
"rb+",
130122
"r+b",

stubs/docutils/docutils/__init__.pyi

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1-
from typing import Any
1+
from collections.abc import Sequence
2+
from typing import Any, ClassVar, NamedTuple, Optional, Tuple, Union
23

3-
def __getattr__(name: str) -> Any: ...
4+
__docformat__: str
5+
__version__: str
6+
7+
class _VersionInfo(NamedTuple):
8+
major: int
9+
minor: int
10+
micro: int
11+
releaselevel: str
12+
serial: int
13+
release: bool
14+
15+
class VersionInfo(_VersionInfo):
16+
def __new__(
17+
cls, major: int = ..., minor: int = ..., micro: int = ..., releaselevel: str = ..., serial: int = ..., release: bool = ...
18+
) -> VersionInfo: ...
19+
20+
__version_info__: VersionInfo
21+
__version_details__: str
22+
23+
class ApplicationError(Exception): ...
24+
class DataError(ApplicationError): ...
25+
26+
class SettingsSpec:
27+
settings_spec: ClassVar[Tuple[Any, ...]]
28+
settings_defaults: ClassVar[Optional[dict[Any, Any]]]
29+
settings_default_overrides: ClassVar[Optional[dict[Any, Any]]]
30+
relative_path_settings: ClassVar[Tuple[Any, ...]]
31+
config_section: ClassVar[Optional[str]]
32+
config_section_dependencies: ClassVar[Optional[Tuple[str, ...]]]
33+
34+
class TransformSpec:
35+
def get_transforms(self) -> list[Any]: ...
36+
default_transforms: ClassVar[Tuple[Any, ...]]
37+
unknown_reference_resolvers: ClassVar[list[Any]]
38+
39+
class Component(SettingsSpec, TransformSpec):
40+
component_type: ClassVar[Optional[str]]
41+
supported: ClassVar[Tuple[str, ...]]
42+
def supports(self, format: str) -> bool: ...

stubs/docutils/docutils/core.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ... # incomplete

stubs/docutils/docutils/examples.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
from typing import Any
22

3-
html_parts: Any
4-
5-
def __getattr__(name: str) -> Any: ...
3+
def __getattr__(name: str) -> Any: ... # incomplete

stubs/docutils/docutils/frontend.pyi

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import optparse
2+
from configparser import RawConfigParser
3+
from typing import Any, ClassVar, Optional, Tuple
4+
5+
from docutils import SettingsSpec
6+
from docutils.utils import DependencyList
7+
8+
__docformat__: str
9+
10+
def store_multiple(option, opt, value, parser, *args, **kwargs) -> None: ...
11+
def read_config_file(option, opt, value, parser) -> None: ...
12+
def validate_encoding(setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...): ...
13+
def validate_encoding_error_handler(
14+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
15+
): ...
16+
def validate_encoding_and_error_handler(
17+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
18+
): ...
19+
def validate_boolean(
20+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
21+
) -> bool: ...
22+
def validate_nonnegative_int(
23+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
24+
) -> int: ...
25+
def validate_threshold(
26+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
27+
) -> int: ...
28+
def validate_colon_separated_string_list(
29+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
30+
) -> list[str]: ...
31+
def validate_comma_separated_list(
32+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
33+
) -> list[str]: ...
34+
def validate_url_trailing_slash(
35+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
36+
) -> str: ...
37+
def validate_dependency_file(
38+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
39+
) -> DependencyList: ...
40+
def validate_strip_class(
41+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
42+
): ...
43+
def validate_smartquotes_locales(
44+
setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...
45+
) -> list[tuple[str, str]]: ...
46+
def make_paths_absolute(pathdict, keys, base_path: Optional[Any] = ...) -> None: ...
47+
def make_one_path_absolute(base_path, path) -> str: ...
48+
def filter_settings_spec(settings_spec, *exclude, **replace) -> Tuple[Any, ...]: ...
49+
50+
class Values(optparse.Values):
51+
def update(self, other_dict, option_parser) -> None: ...
52+
def copy(self) -> Values: ...
53+
54+
class Option(optparse.Option): ...
55+
56+
class OptionParser(optparse.OptionParser, SettingsSpec):
57+
standard_config_files: ClassVar[list[str]]
58+
threshold_choices: ClassVar[list[str]]
59+
thresholds: ClassVar[dict[str, int]]
60+
booleans: ClassVar[dict[str, bool]]
61+
default_error_encoding: ClassVar[str]
62+
default_error_encoding_error_handler: ClassVar[str]
63+
config_section: ClassVar[str]
64+
version_template: ClassVar[str]
65+
def __getattr__(self, name: str) -> Any: ... # incomplete
66+
67+
class ConfigParser(RawConfigParser):
68+
def __getattr__(self, name: str) -> Any: ... # incomplete
69+
70+
class ConfigDeprecationWarning(DeprecationWarning): ...

stubs/docutils/docutils/io.pyi

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from _typeshed import OpenBinaryModeReading, OpenBinaryModeWriting, OpenTextModeReading, OpenTextModeWriting
2+
from typing import Any, ClassVar, Optional, Union
3+
4+
from docutils import TransformSpec
5+
6+
__docformat__: str
7+
8+
class InputError(IOError): ...
9+
class OutputError(IOError): ...
10+
11+
def check_encoding(stream: Any, encoding: str) -> Optional[bool]: ...
12+
13+
class Input(TransformSpec):
14+
component_type: ClassVar[str]
15+
default_source_path: ClassVar[Optional[str]]
16+
def read(self) -> Any: ...
17+
def __getattr__(self, name: str) -> Any: ... # incomplete
18+
19+
class Output(TransformSpec):
20+
component_type: ClassVar[str]
21+
default_destination_path: ClassVar[Optional[str]]
22+
def __init__(
23+
self,
24+
destination: Optional[Any] = ...,
25+
destination_path: Optional[Any] = ...,
26+
encoding: Optional[str] = ...,
27+
error_handler: str = ...,
28+
) -> None: ...
29+
def write(self, data: str) -> Any: ... # returns bytes or str
30+
def encode(self, data: str) -> Any: ... # returns bytes or str
31+
32+
class FileInput(Input):
33+
def __init__(
34+
self,
35+
source: Optional[Any] = ...,
36+
source_path: Optional[Any] = ...,
37+
encoding: Optional[str] = ...,
38+
error_handler: str = ...,
39+
autoclose: bool = ...,
40+
mode: Union[OpenTextModeReading, OpenBinaryModeReading] = ...,
41+
) -> None: ...
42+
def readlines(self) -> list[str]: ...
43+
def close(self) -> None: ...
44+
45+
class FileOutput(Output):
46+
mode: ClassVar[Union[OpenTextModeWriting, OpenBinaryModeWriting]]
47+
def __getattr__(self, name: str) -> Any: ... # incomplete
48+
49+
class BinaryFileOutput(FileOutput): ...
50+
51+
class StringInput(Input):
52+
default_source_path: ClassVar[str]
53+
54+
class StringOutput(Output):
55+
default_destination_path: ClassVar[str]
56+
destination: Union[str, bytes] # only defined after call to write()
57+
58+
class NullInput(Input):
59+
default_source_path: ClassVar[str]
60+
def read(self) -> str: ...
61+
62+
class NullOutput(Output):
63+
default_destination_path: ClassVar[str]
64+
def write(self, data: object) -> None: ...
65+
66+
class DocTreeInput(Input):
67+
default_source_path: ClassVar[str]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ... # incomplete

stubs/docutils/docutils/nodes.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ from typing import Any, List
33
class reference:
44
def __init__(self, rawsource: str = ..., text: str = ..., *children: List[Any], **attributes: Any) -> None: ...
55

6-
def __getattr__(name: str) -> Any: ...
6+
def __getattr__(name: str) -> Any: ... # incomplete
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1-
from typing import Any
1+
from typing import Any, ClassVar, Type
22

3-
def __getattr__(name: str) -> Any: ...
3+
from docutils import Component
4+
5+
class Parser(Component):
6+
component_type: ClassVar[str]
7+
config_section: ClassVar[str]
8+
inputstring: Any # defined after call to setup_parse()
9+
document: Any # defined after call to setup_parse()
10+
def parse(self, inputstring: str, document) -> None: ...
11+
def setup_parse(self, inputstring: str, document) -> None: ...
12+
def finish_parse(self) -> None: ...
13+
14+
_parser_aliases: dict[str, str]
15+
16+
def get_parser_class(parser_name: str) -> Type[Parser]: ...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from typing import ClassVar, Tuple
2+
3+
from docutils import parsers
4+
5+
class Parser(parsers.Parser):
6+
config_section_dependencies: ClassVar[Tuple[str, ...]]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ... # incomplete
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1-
from typing import Any
1+
from typing import Any, ClassVar, Optional, Tuple
2+
from typing_extensions import Literal
23

3-
def __getattr__(name: str) -> Any: ...
4+
from docutils import parsers
5+
6+
class Parser(parsers.Parser):
7+
config_section_dependencies: ClassVar[Tuple[str, ...]]
8+
initial_state: Literal["Body", "RFC2822Body"]
9+
state_classes: Any
10+
inliner: Any
11+
def __init__(self, rfc2822: bool = ..., inliner: Optional[Any] = ...) -> None: ...
12+
13+
class DirectiveError(Exception):
14+
level: Any
15+
msg: str
16+
def __init__(self, level: Any, message: str) -> None: ...
17+
18+
class Directive:
19+
def __getattr__(self, name: str) -> Any: ... # incomplete
20+
21+
def convert_directive_function(directive_fn): ...
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from typing import Any
22

3-
def __getattr__(name: str) -> Any: ...
3+
def __getattr__(name: str) -> Any: ... # incomplete

stubs/docutils/docutils/parsers/rst/states.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ from typing import Any
33
class Inliner:
44
def __init__(self) -> None: ...
55

6-
def __getattr__(name: str) -> Any: ...
6+
def __getattr__(name: str) -> Any: ... # incomplete
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ... # incomplete
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ... # incomplete
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ... # incomplete
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ... # incomplete
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ... # incomplete
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ... # incomplete
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from collections.abc import Iterable
2+
from typing import Any, Optional
3+
4+
from docutils.io import FileOutput
5+
6+
class DependencyList:
7+
list: list[str]
8+
file: Optional[FileOutput]
9+
def __init__(self, output_file: Optional[str] = ..., dependencies: Iterable[str] = ...) -> None: ...
10+
def set_output(self, output_file: Optional[str]) -> None: ...
11+
def add(self, *filenames: str) -> None: ...
12+
def close(self) -> None: ...
13+
14+
def __getattr__(name: str) -> Any: ... # incomplete
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Any
2+
3+
def __getattr__(name: str) -> Any: ... # incomplete

0 commit comments

Comments
 (0)