Skip to content

Commit f8e7386

Browse files
authored
add intermediate classes in selectors module (#11164)
1 parent a53bfeb commit f8e7386

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

stdlib/selectors.pyi

+13-25
Original file line numberDiff line numberDiff line change
@@ -31,49 +31,37 @@ class BaseSelector(metaclass=ABCMeta):
3131
def __enter__(self) -> Self: ...
3232
def __exit__(self, *args: Unused) -> None: ...
3333

34-
class SelectSelector(BaseSelector):
34+
class _BaseSelectorImpl(BaseSelector, metaclass=ABCMeta):
3535
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
3636
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
37-
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
37+
def modify(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
3838
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
3939

40+
class SelectSelector(_BaseSelectorImpl):
41+
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
42+
43+
class _PollLikeSelector(_BaseSelectorImpl):
44+
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
45+
4046
if sys.platform != "win32":
41-
class PollSelector(BaseSelector):
42-
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
43-
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
44-
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
45-
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
47+
class PollSelector(_PollLikeSelector): ...
4648

4749
if sys.platform == "linux":
48-
class EpollSelector(BaseSelector):
50+
class EpollSelector(_PollLikeSelector):
4951
def fileno(self) -> int: ...
50-
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
51-
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
52-
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
53-
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
5452

55-
class DevpollSelector(BaseSelector):
53+
class DevpollSelector(_PollLikeSelector):
5654
def fileno(self) -> int: ...
57-
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ...
58-
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
59-
def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ...
60-
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
6155

6256
if sys.platform != "win32":
63-
class KqueueSelector(BaseSelector):
57+
class KqueueSelector(_BaseSelectorImpl):
6458
def fileno(self) -> int: ...
65-
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
66-
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
6759
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
68-
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
6960

7061
# Not a real class at runtime, it is just a conditional alias to other real selectors.
7162
# The runtime logic is more fine-grained than a `sys.platform` check;
7263
# not really expressible in the stubs
73-
class DefaultSelector(BaseSelector):
74-
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
75-
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
64+
class DefaultSelector(_BaseSelectorImpl):
7665
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
77-
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
7866
if sys.platform != "win32":
7967
def fileno(self) -> int: ...

0 commit comments

Comments
 (0)