Skip to content

Commit fbf2199

Browse files
authored
Various stubtest fixes (#5230)
1 parent f44f38f commit fbf2199

File tree

14 files changed

+46
-46
lines changed

14 files changed

+46
-46
lines changed

stdlib/random.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _random
22
import sys
33
from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set
4-
from typing import Any, Optional, Tuple, TypeVar, Union
4+
from typing import Any, NoReturn, Optional, Tuple, TypeVar, Union
55

66
_T = TypeVar("_T")
77

@@ -45,7 +45,9 @@ class Random(_random.Random):
4545
def weibullvariate(self, alpha: float, beta: float) -> float: ...
4646

4747
# SystemRandom is not implemented for all OS's; good on Windows & Linux
48-
class SystemRandom(Random): ...
48+
class SystemRandom(Random):
49+
def getstate(self, *args: Any, **kwds: Any) -> NoReturn: ...
50+
def setstate(self, *args: Any, **kwds: Any) -> NoReturn: ...
4951

5052
# ----- random function stubs -----
5153
def seed(a: Any = ..., version: int = ...) -> None: ...

stdlib/re.pyi

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import enum
22
import sys
3+
from sre_constants import error as error
34
from typing import Any, AnyStr, Callable, Iterator, List, Optional, Tuple, Union, overload
45

56
# ----- re variables and constants -----
@@ -50,13 +51,6 @@ if sys.version_info < (3, 7):
5051
# undocumented
5152
_pattern_type: type
5253

53-
class error(Exception):
54-
msg: str
55-
pattern: str
56-
pos: Optional[int]
57-
lineno: Optional[int]
58-
colno: Optional[int]
59-
6054
@overload
6155
def compile(pattern: AnyStr, flags: _FlagsType = ...) -> Pattern[AnyStr]: ...
6256
@overload

stdlib/runpy.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ class _ModifiedArgv0:
1919
def run_module(
2020
mod_name: str, init_globals: Optional[Dict[str, Any]] = ..., run_name: Optional[str] = ..., alter_sys: bool = ...
2121
) -> Dict[str, Any]: ...
22-
def run_path(path_name: str, init_globals: Optional[Dict[str, Any]] = ..., run_name: str = ...) -> Dict[str, Any]: ...
22+
def run_path(path_name: str, init_globals: Optional[Dict[str, Any]] = ..., run_name: Optional[str] = ...) -> Dict[str, Any]: ...

stdlib/shutil.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ if sys.version_info >= (3,):
159159
# See http://bugs.python.org/issue30218
160160
def unpack_archive(filename: str, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ...
161161
def register_unpack_format(
162-
name: str, extensions: List[str], function: Any, extra_args: Sequence[Tuple[str, Any]] = ..., description: str = ...
162+
name: str,
163+
extensions: List[str],
164+
function: Any,
165+
extra_args: Optional[Sequence[Tuple[str, Any]]] = ...,
166+
description: str = ...,
163167
) -> None: ...
164168
def unregister_unpack_format(name: str) -> None: ...
165169
def get_unpack_formats() -> List[Tuple[str, List[str], str]]: ...

stdlib/smtpd.pyi

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,21 @@ class SMTPServer(asyncore.dispatcher):
8484
) -> Optional[str]: ...
8585

8686
class DebuggingServer(SMTPServer): ...
87-
class PureProxy(SMTPServer): ...
88-
class MailmanProxy(PureProxy): ...
87+
88+
class PureProxy(SMTPServer):
89+
def process_message( # type: ignore
90+
self,
91+
peer: _Address,
92+
mailfrom: str,
93+
rcpttos: List[Text],
94+
data: Union[bytes, str],
95+
) -> Optional[str]: ...
96+
97+
class MailmanProxy(PureProxy):
98+
def process_message( # type: ignore
99+
self,
100+
peer: _Address,
101+
mailfrom: str,
102+
rcpttos: List[Text],
103+
data: Union[bytes, str],
104+
) -> Optional[str]: ...

stdlib/smtplib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class SMTP:
124124
msg: _Message,
125125
from_addr: Optional[str] = ...,
126126
to_addrs: Optional[Union[str, Sequence[str]]] = ...,
127-
mail_options: List[str] = ...,
127+
mail_options: Sequence[str] = ...,
128128
rcpt_options: Sequence[str] = ...,
129129
) -> _SendErrs: ...
130130
def close(self) -> None: ...

stdlib/sqlite3/dbapi2.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def DateFromTicks(ticks: float) -> Date: ...
1616
def TimeFromTicks(ticks: float) -> Time: ...
1717
def TimestampFromTicks(ticks: float) -> Timestamp: ...
1818

19-
version_info: str
19+
version_info: Tuple[int, int, int]
2020
sqlite_version_info: Tuple[int, int, int]
2121
if sys.version_info >= (3,):
2222
Binary = memoryview
@@ -289,7 +289,7 @@ class Row(object):
289289
def __hash__(self): ...
290290
def __iter__(self): ...
291291
def __le__(self, other): ...
292-
def __len__(self, *args: Any, **kwargs: Any): ...
292+
def __len__(self): ...
293293
def __lt__(self, other): ...
294294
def __ne__(self, other): ...
295295

stdlib/sre_constants.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class error(Exception):
88
pos: Optional[int]
99
lineno: int
1010
colno: int
11-
def __init__(self, msg: str, pattern: Union[str, bytes] = ..., pos: int = ...) -> None: ...
11+
def __init__(self, msg: str, pattern: Optional[Union[str, bytes]] = ..., pos: Optional[int] = ...) -> None: ...
1212

1313
class _NamedIntConstant(int):
1414
name: Any

stdlib/sunau.pyi

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,11 @@ class Au_write:
6666
def getframerate(self) -> int: ...
6767
def setnframes(self, nframes: int) -> None: ...
6868
def getnframes(self) -> int: ...
69-
def setcomptype(self, comptype: str, compname: str) -> None: ...
69+
def setcomptype(self, type: str, name: str) -> None: ...
7070
def getcomptype(self) -> str: ...
7171
def getcompname(self) -> str: ...
7272
def setparams(self, params: _sunau_params) -> None: ...
7373
def getparams(self) -> _sunau_params: ...
74-
def setmark(self, id: Any, pos: Any, name: Any) -> NoReturn: ...
75-
def getmark(self, id: Any) -> NoReturn: ...
76-
def getmarkers(self) -> None: ...
7774
def tell(self) -> int: ...
7875
# should be any bytes-like object after 3.4, but we don't have a type for that
7976
def writeframesraw(self, data: bytes) -> None: ...

tests/stubtest_whitelists/py36.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ plistlib.Dict.__init__
3737
pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args
3838
random.Random.randrange # missing undocumented arg _int
3939
random.randrange # missing undocumented arg _int
40+
sched.Event.__doc__ # __slots__ is overridden
4041
secrets.SystemRandom.getstate
4142
smtplib.SMTP.sendmail
4243
sre_compile.dis

tests/stubtest_whitelists/py37.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - funct
4747
queue.SimpleQueue.__init__
4848
random.Random.randrange # missing undocumented arg _int
4949
random.randrange # missing undocumented arg _int
50+
sched.Event.__doc__ # __slots__ is overridden
5051
secrets.SystemRandom.getstate
5152
smtplib.SMTP.sendmail
5253
sre_constants.RANGE_IGNORE

tests/stubtest_whitelists/py38.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ platform.DEV_NULL
7070
queue.SimpleQueue.__init__
7171
random.Random.randrange # missing undocumented arg _int
7272
random.randrange # missing undocumented arg _int
73+
sched.Event.__doc__ # __slots__ is overridden
7374
secrets.SystemRandom.getstate
7475
select.epoll.register
7576
smtplib.SMTP.sendmail

tests/stubtest_whitelists/py39.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ platform.uname_result.__new__
9090
platform.uname_result._fields
9191
platform.uname_result.processor
9292
queue.SimpleQueue.__init__
93+
sched.Event.__doc__ # __slots__ is overridden
9394
secrets.SystemRandom.getstate
9495
select.epoll.register
9596
smtplib.LMTP.__init__

tests/stubtest_whitelists/py3_common.txt

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -213,35 +213,18 @@ pydoc.TextDoc.docmodule
213213
pydoc.TextDoc.docother
214214
pydoc.TextDoc.docproperty
215215
pydoc.TextDoc.docroutine
216-
random.SystemRandom.getstate
217-
re.error.__init__
218-
runpy.run_path
219-
sched.Event.__doc__
220-
select.poll
221-
selectors.DevpollSelector
222-
selectors.KqueueSelector
223-
shutil.register_unpack_format
224-
signal.SIGEMT
225-
signal.SIGINFO
226-
smtpd.MailmanProxy.process_message
227-
smtpd.PureProxy.process_message
228-
smtplib.SMTP.send_message
229-
socketserver.BaseServer.fileno
230-
socketserver.BaseServer.get_request
231-
socketserver.BaseServer.server_bind
232-
sqlite3.Row.__len__
233-
sqlite3.dbapi2.Row.__len__
234-
sqlite3.dbapi2.version_info
235-
sqlite3.version_info
236-
sre_constants.error.__init__
216+
select.poll # Depends on configuration
217+
selectors.DevpollSelector # Depends on configuration
218+
selectors.KqueueSelector # Depends on system
219+
signal.SIGEMT # Depends on system
220+
signal.SIGINFO # Depends on system
221+
socketserver.BaseServer.fileno # implemented in derived classes
222+
socketserver.BaseServer.get_request # implemented in derived classes
223+
socketserver.BaseServer.server_bind # implemented in derived classes
237224
ssl.PROTOCOL_SSLv2 # Defined only if compiled with ssl v2
238225
ssl.Purpose.__new__ # You cannot override __new__ in NamedTuple and runtime uses namedtuple.
239226
ssl._ASN1Object.__new__ # You cannot override __new__ in NamedTuple and runtime uses namedtuple.
240227
subprocess.Popen.__init__
241-
sunau.Au_write.getmark
242-
sunau.Au_write.getmarkers
243-
sunau.Au_write.setcomptype
244-
sunau.Au_write.setmark
245228
sys.gettotalrefcount # Available on python debug builds
246229
sys.implementation # Actually SimpleNamespace but then you wouldn't have convenient attributes
247230
tarfile.TarFile.errors # errors is initialized for some reason as None even though it really only accepts str

0 commit comments

Comments
 (0)