diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index befc81870355..01622a4fd76a 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -4,6 +4,7 @@ import ssl import sys from _typeshed import Self from typing import IO, Any, Iterable, NamedTuple, Union +from typing_extensions import Literal _File = Union[IO[bytes], bytes, str, None] @@ -16,8 +17,8 @@ class NNTPPermanentError(NNTPError): ... class NNTPProtocolError(NNTPError): ... class NNTPDataError(NNTPError): ... -NNTP_PORT: int -NNTP_SSL_PORT: int +NNTP_PORT: Literal[119] +NNTP_SSL_PORT: Literal[563] class GroupInfo(NamedTuple): group: str @@ -34,11 +35,13 @@ def decode_header(header_str: str) -> str: ... _list = list # conflicts with a method named "list" -class _NNTPBase: +class NNTP: encoding: str errors: str host: str + port: int + sock: socket.socket file: IO[bytes] debugging: int welcome: str @@ -47,7 +50,16 @@ class _NNTPBase: authenticated: bool nntp_implementation: str nntp_version: int - def __init__(self, file: IO[bytes], host: str, readermode: bool | None = ..., timeout: float = ...) -> None: ... + def __init__( + self, + host: str, + port: int = ..., + user: str | None = ..., + password: str | None = ..., + readermode: bool | None = ..., + usenetrc: bool = ..., + timeout: float = ..., + ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, *args: Any) -> None: ... def getwelcome(self) -> str: ... @@ -85,22 +97,9 @@ class _NNTPBase: def login(self, user: str | None = ..., password: str | None = ..., usenetrc: bool = ...) -> None: ... def starttls(self, context: ssl.SSLContext | None = ...) -> None: ... -class NNTP(_NNTPBase): - port: int - sock: socket.socket - def __init__( - self, - host: str, - port: int = ..., - user: str | None = ..., - password: str | None = ..., - readermode: bool | None = ..., - usenetrc: bool = ..., - timeout: float = ..., - ) -> None: ... - -class NNTP_SSL(_NNTPBase): - sock: socket.socket +class NNTP_SSL(NNTP): + ssl_context: ssl.SSLContext | None + sock: ssl.SSLSocket def __init__( self, host: str,