Fix various py310 stubtest errors (#7239)

This commit is contained in:
Alex Waygood
2022-02-16 19:47:49 +00:00
committed by GitHub
parent fef3a71459
commit 5a8b9dafb3
8 changed files with 69 additions and 31 deletions

View File

@@ -112,6 +112,7 @@ difflib: 2.7-
dis: 2.7-
distutils: 2.7-
distutils.command.bdist_msi: 2.7-3.10
distutils.command.bdist_wininst: 2.7-3.9
doctest: 2.7-
dummy_threading: 2.7-3.8
email: 2.7-

View File

@@ -29,15 +29,27 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr
def get_write_buffer_size(self) -> int: ...
class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport):
def __init__(
self,
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
) -> None: ...
if sys.version_info >= (3, 10):
def __init__(
self,
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
buffer_size: int = ...,
) -> None: ...
else:
def __init__(
self,
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
) -> None: ...
class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport):
def __init__(

View File

@@ -43,4 +43,8 @@ else:
file: AnyStr, cfile: AnyStr | None = ..., dfile: AnyStr | None = ..., doraise: bool = ..., optimize: int = ...
) -> AnyStr | None: ...
def main(args: list[str] | None = ...) -> int: ...
if sys.version_info >= (3, 10):
def main() -> None: ...
else:
def main(args: list[str] | None = ...) -> int: ...

View File

@@ -1,13 +1,24 @@
import sys
from typing import Any, Callable, NamedTuple
__all__ = ["scheduler"]
class Event(NamedTuple):
time: float
priority: Any
action: Callable[..., Any]
argument: tuple[Any, ...]
kwargs: dict[str, Any]
if sys.version_info >= (3, 10):
class Event(NamedTuple):
time: float
priority: Any
sequence: int
action: Callable[..., Any]
argument: tuple[Any, ...]
kwargs: dict[str, Any]
else:
class Event(NamedTuple):
time: float
priority: Any
action: Callable[..., Any]
argument: tuple[Any, ...]
kwargs: dict[str, Any]
class scheduler:
timefunc: Callable[[], float]

View File

@@ -63,7 +63,7 @@ SIG_IGN: Handlers
_SIGNUM = Union[int, Signals]
_HANDLER = Union[Callable[[int, Optional[FrameType]], Any], int, Handlers, None]
def default_int_handler(signum: int, frame: FrameType | None) -> None: ...
def default_int_handler(__signalnum: int, __frame: FrameType | None) -> None: ...
if sys.version_info >= (3, 10): # arguments changed in 3.10.2
def getsignal(signalnum: _SIGNUM) -> _HANDLER: ...

View File

@@ -3,9 +3,11 @@ from typing import Any, TypeVar
from typing_extensions import final
ucd_3_2_0: UCD
ucnhash_CAPI: Any
unidata_version: str
if sys.version_info < (3, 10):
ucnhash_CAPI: Any
_T = TypeVar("_T")
def bidirectional(__chr: str) -> str: ...

View File

@@ -442,9 +442,22 @@ class _ANY:
ANY: Any
def create_autospec(
spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Any | None = ..., _name: Any | None = ..., **kwargs: Any
) -> Any: ...
if sys.version_info >= (3, 10):
def create_autospec(
spec: Any,
spec_set: Any = ...,
instance: Any = ...,
_parent: Any | None = ...,
_name: Any | None = ...,
*,
unsafe: bool = ...,
**kwargs: Any,
) -> Any: ...
else:
def create_autospec(
spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Any | None = ..., _name: Any | None = ..., **kwargs: Any
) -> Any: ...
class _SpecState:
spec: Any

View File

@@ -129,17 +129,13 @@ os.path.join
pstats.SortKey.__new__
tkinter.EventType.__new__
# Rest of these errors are new in Python 3.10:
asyncio.proactor_events._ProactorReadPipeTransport.__init__
distutils.command.bdist_wininst
py_compile.main
sched.Event.__new__
sched.Event._fields
signal.default_int_handler
distutils.command.bdist_wininst # removed in 3.10
# stubtest complains that in 3.10 the default argument is inconsistent with the annotation,
# but in 3.10+ calling the function without the default argument is in fact deprecated,
# so it's better to ignore stubtest
ssl.SSLContext.__new__
ssl._create_unverified_context
unicodedata.ucnhash_CAPI
unittest.mock.create_autospec
# Exists at runtime, but missing from stubs
_ast.Tuple.dims
@@ -169,7 +165,6 @@ multiprocessing.managers.SharedMemoryServer.shutdown
multiprocessing.managers.SharedMemoryServer.track_segment
pyexpat.XMLParserType.SkippedEntityHandler
pyexpat.XMLParserType.intern
sched.Event.sequence
types.CoroutineType.cr_origin
typing._SpecialForm.__call__
unicodedata.UCD.is_normalized