Skip to content

Commit 4a83a4b

Browse files
author
Jakub Stasiak
committed
Add BaseRequestHandler instance attributes
From the BaseRequestHandler documentation: handle() This function must do all the work required to service a request. The default implementation does nothing. Several instance attributes are available to it; the request is available as self.request; the client address as self.client_address; and the server instance as self.server, in case it needs access to per-server information. The type of self.request is different for datagram or stream services. For stream services, self.request is a socket object; for datagram services, self.request is a pair of string and socket.
1 parent c1b1297 commit 4a83a4b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

stdlib/3/socketserver.pyi

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Stubs for socketserver
22

3-
from typing import BinaryIO, Optional, Tuple
3+
from typing import Any, BinaryIO, Optional, Tuple
44
from socket import SocketType
55
import sys
66
import types
@@ -68,7 +68,18 @@ class ForkingUDPServer(ForkingMixIn, UDPServer): ...
6868
class ThreadingTCPServer(ThreadingMixIn, TCPServer): ...
6969
class ThreadingUDPServer(ThreadingMixIn, UDPServer): ...
7070

71+
7172
class BaseRequestHandler:
73+
# Those are technically of types, respectively:
74+
# * Union[SocketType, Tuple[bytes, SocketType]]
75+
# * Union[Tuple[str, int], str]
76+
# But there are some concerns that having unions here would cause
77+
# too much inconvenience to people using it (see
78+
# https://github.com/python/typeshed/pull/384#issuecomment-234649696)
79+
request = ... # type: Any
80+
client_address = ... # type: Any
81+
82+
server = ... # type: BaseServer
7283
def setup(self) -> None: ...
7384
def handle(self) -> None: ...
7485
def finish(self) -> None: ...

0 commit comments

Comments
 (0)