-
Notifications
You must be signed in to change notification settings - Fork 2
/
select_.py
93 lines (81 loc) · 2.73 KB
/
select_.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""
Generate `pyi` from corresponding `rst` docs.
"""
import rst
from rst2pyi import RST2PyI
__author__ = rst.__author__
__copyright__ = rst.__copyright__
__license__ = rst.__license__
__version__ = "7.5.3" # Version set by https://github.com/hlovatt/tag2ver
def select(shed: RST2PyI) -> None:
shed.module(
name="select",
old="wait for events on a set of streams",
post_doc=f'''
from typing import Iterable, Any, Final, Iterator
from uio import IOBase
POLLIN: Final[int] = ...
"""Data available for reading."""
POLLOUT: Final[int] = ...
"""More data can be written."""
POLLHUP: Final[int] = ...
"""Socket is no longer connected."""
POLLERR: Final[int] = ...
"""Socket got an asynchronous error."""
''',
end="Functions",
)
shed.def_(
old=r".. function:: poll()", new='def poll() -> "Poll"', indent=0,
)
shed.def_(
old=r".. function:: select(rlist, wlist, xlist[, timeout])",
new="""
def select(
rlist: Iterable[Any],
wlist: Iterable[Any],
xlist: Iterable[Any],
timeout: int = -1,
/,
) -> list[tuple[Any, int, Any, ...]]
""",
indent=0,
)
# .. _class: Poll` is in `rst` file but not rendered by Sphinx (has no description either)!
# It is ignored along with the `class ``Pol``` and `Method` headers in the `rst` file.
shed.consume_minuses_underline_line(and_preceding_lines=True)
shed.consume_tildes_underline_line(and_preceding_lines=True)
shed.class_(
name="Poll",
extra_docs=[
"""
The name, `Poll`, used for typing is not the same as the runtime name, `poll` (note lowercase `p`).
The reason for this difference is that the runtime uses `poll` as both a class name and as a method name and
this is not possible within code written entirely in Python and therefore not possible within typing code.
""".strip(
"\n"
)
],
end=r".. method:: ",
)
shed.def_(
old=r".. method:: poll.register(obj[, eventmask])",
new="def register(self, obj: IOBase, eventmask: int = POLLIN | POLLOUT, /) -> None",
)
shed.def_(
old=r".. method:: poll.unregister(obj)",
new="def unregister(self, obj: IOBase, /) -> None",
)
shed.def_(
old=r".. method:: poll.modify(obj, eventmask)",
new="def modify(self, obj: IOBase, eventmask: int, /) -> None",
)
shed.def_(
old=r".. method:: poll.poll(timeout=-1, /)",
new="def poll(self, timeout: int = -1, /) -> list[tuple[Any, int, Any, ...]]",
)
shed.def_(
old=r".. method:: poll.ipoll(timeout=-1, flags=0, /)",
new="def ipoll(self, timeout: int = -1, flags: int = 0, /) -> Iterator[tuple[Any, int, Any, ...]]",
)
shed.write(u_also=True)