@@ -4,6 +4,7 @@ import ssl
4
4
import sys
5
5
from _typeshed import Self
6
6
from typing import IO , Any , Iterable , NamedTuple , Union
7
+ from typing_extensions import Literal
7
8
8
9
_File = Union [IO [bytes ], bytes , str , None ]
9
10
@@ -16,8 +17,8 @@ class NNTPPermanentError(NNTPError): ...
16
17
class NNTPProtocolError (NNTPError ): ...
17
18
class NNTPDataError (NNTPError ): ...
18
19
19
- NNTP_PORT : int
20
- NNTP_SSL_PORT : int
20
+ NNTP_PORT : Literal [ 119 ]
21
+ NNTP_SSL_PORT : Literal [ 563 ]
21
22
22
23
class GroupInfo (NamedTuple ):
23
24
group : str
@@ -34,11 +35,13 @@ def decode_header(header_str: str) -> str: ...
34
35
35
36
_list = list # conflicts with a method named "list"
36
37
37
- class _NNTPBase :
38
+ class NNTP :
38
39
encoding : str
39
40
errors : str
40
41
41
42
host : str
43
+ port : int
44
+ sock : socket .socket
42
45
file : IO [bytes ]
43
46
debugging : int
44
47
welcome : str
@@ -47,7 +50,16 @@ class _NNTPBase:
47
50
authenticated : bool
48
51
nntp_implementation : str
49
52
nntp_version : int
50
- def __init__ (self , file : IO [bytes ], host : str , readermode : bool | None = ..., timeout : float = ...) -> None : ...
53
+ def __init__ (
54
+ self ,
55
+ host : str ,
56
+ port : int = ...,
57
+ user : str | None = ...,
58
+ password : str | None = ...,
59
+ readermode : bool | None = ...,
60
+ usenetrc : bool = ...,
61
+ timeout : float = ...,
62
+ ) -> None : ...
51
63
def __enter__ (self : Self ) -> Self : ...
52
64
def __exit__ (self , * args : Any ) -> None : ...
53
65
def getwelcome (self ) -> str : ...
@@ -85,22 +97,9 @@ class _NNTPBase:
85
97
def login (self , user : str | None = ..., password : str | None = ..., usenetrc : bool = ...) -> None : ...
86
98
def starttls (self , context : ssl .SSLContext | None = ...) -> None : ...
87
99
88
- class NNTP (_NNTPBase ):
89
- port : int
90
- sock : socket .socket
91
- def __init__ (
92
- self ,
93
- host : str ,
94
- port : int = ...,
95
- user : str | None = ...,
96
- password : str | None = ...,
97
- readermode : bool | None = ...,
98
- usenetrc : bool = ...,
99
- timeout : float = ...,
100
- ) -> None : ...
101
-
102
- class NNTP_SSL (_NNTPBase ):
103
- sock : socket .socket
100
+ class NNTP_SSL (NNTP ):
101
+ ssl_context : ssl .SSLContext | None
102
+ sock : ssl .SSLSocket
104
103
def __init__ (
105
104
self ,
106
105
host : str ,
0 commit comments