Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjusting socketserver.BaseServer #13082

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions stdlib/@tests/stubtest_allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ http.client.HTTPConnection.response_class # the actual type at runtime is abc.A
importlib.abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined for backwards compatibility
importlib.abc.MetaPathFinder.find_spec # Not defined on the actual class, but expected to exist.
importlib.abc.PathEntryFinder.find_spec # Not defined on the actual class, but expected to exist.
socketserver.BaseServer.fileno # implemented in derived classes
socketserver.BaseServer.get_request # implemented in derived classes
socketserver.BaseServer.server_bind # implemented in derived classes
tkinter.simpledialog.[A-Z_]+
tkinter.simpledialog.TclVersion
tkinter.simpledialog.TkVersion
Expand Down Expand Up @@ -389,6 +386,7 @@ pickle._Pickler\..* # Best effort typing for undocumented internals
pickle._Unpickler\..* # Best effort typing for undocumented internals
_?queue.SimpleQueue.__init__ # C signature is broader than what is actually accepted
shutil.rmtree # function with attributes, which we approximate with a callable protocol
socketserver.BaseServer.get_request # Not implemented, but expected to exist on subclasses.
ssl.PROTOCOL_SSLv2 # Depends on the existence and flags of SSL
ssl.PROTOCOL_SSLv3 # Depends on the existence and flags of SSL
sys.implementation # Actually SimpleNamespace but then you wouldn't have convenient attributes
Expand Down
16 changes: 8 additions & 8 deletions stdlib/socketserver.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,22 @@ _AfInetAddress: TypeAlias = tuple[str | bytes | bytearray, int] # address accep

# This can possibly be generic at some point:
class BaseServer:
address_family: int
server_address: _Address
socket: _socket
allow_reuse_address: bool
request_queue_size: int
socket_type: int
timeout: float | None
RequestHandlerClass: Callable[[Any, _RetAddress, Self], BaseRequestHandler]
def __init__(
self, server_address: _Address, RequestHandlerClass: Callable[[Any, _RetAddress, Self], BaseRequestHandler]
) -> None: ...
def fileno(self) -> int: ...
def handle_request(self) -> None: ...
def serve_forever(self, poll_interval: float = 0.5) -> None: ...
def shutdown(self) -> None: ...
def server_close(self) -> None: ...
def finish_request(self, request: _RequestType, client_address: _RetAddress) -> None: ...
def get_request(self) -> tuple[Any, Any]: ...
def get_request(self) -> tuple[Any, Any]: ... # Not implemented here, but expected to exist on subclasses
def handle_error(self, request: _RequestType, client_address: _RetAddress) -> None: ...
def handle_timeout(self) -> None: ...
def process_request(self, request: _RequestType, client_address: _RetAddress) -> None: ...
def server_activate(self) -> None: ...
def server_bind(self) -> None: ...
def verify_request(self, request: _RequestType, client_address: _RetAddress) -> bool: ...
def __enter__(self) -> Self: ...
def __exit__(
Expand All @@ -71,6 +64,11 @@ class BaseServer:
def close_request(self, request: _RequestType) -> None: ... # undocumented

class TCPServer(BaseServer):
address_family: int
socket: _socket
allow_reuse_address: bool
request_queue_size: int
socket_type: int
if sys.version_info >= (3, 11):
allow_reuse_port: bool
server_address: _AfInetAddress
Expand All @@ -80,7 +78,9 @@ class TCPServer(BaseServer):
RequestHandlerClass: Callable[[Any, _RetAddress, Self], BaseRequestHandler],
bind_and_activate: bool = True,
) -> None: ...
def fileno(self) -> int: ...
def get_request(self) -> tuple[_socket, _RetAddress]: ...
def server_bind(self) -> None: ...

class UDPServer(TCPServer):
max_packet_size: ClassVar[int]
Expand Down
Loading