Skip to content

Commit a1424d6

Browse files
authored
Merge branch 'master' into 585
2 parents 7ebc422 + 321359c commit a1424d6

File tree

7 files changed

+26
-31
lines changed

7 files changed

+26
-31
lines changed

stdlib/_typeshed/__init__.pyi

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import ctypes
77
import mmap
88
import sys
99
from os import PathLike
10-
from typing import AbstractSet, Any, Awaitable, Container, Generic, Iterable, Protocol, TypeVar
10+
from types import TracebackType
11+
from typing import AbstractSet, Any, Awaitable, Container, Generic, Iterable, Protocol, TypeVar, Union
1112
from typing_extensions import Final, Literal, TypeAlias, final
1213

1314
_KT = TypeVar("_KT")
@@ -197,6 +198,9 @@ WriteableBuffer: TypeAlias = bytearray | memoryview | array.array[Any] | mmap.mm
197198
# Same as _WriteableBuffer, but also includes read-only buffer types (like bytes).
198199
ReadableBuffer: TypeAlias = ReadOnlyBuffer | WriteableBuffer # stable
199200

201+
ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType]
202+
OptExcInfo: TypeAlias = Union[ExcInfo, tuple[None, None, None]]
203+
200204
# stable
201205
if sys.version_info >= (3, 10):
202206
from types import NoneType as NoneType

stdlib/_typeshed/wsgi.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# See the README.md file in this directory for more information.
66

77
import sys
8+
from _typeshed import OptExcInfo
89
from collections.abc import Callable, Iterable
9-
from sys import _OptExcInfo
1010
from typing import Any, Protocol
1111
from typing_extensions import TypeAlias
1212

@@ -20,7 +20,7 @@ else:
2020
# stable
2121
class StartResponse(Protocol):
2222
def __call__(
23-
self, __status: str, __headers: list[tuple[str, str]], __exc_info: _OptExcInfo | None = ...
23+
self, __status: str, __headers: list[tuple[str, str]], __exc_info: OptExcInfo | None = ...
2424
) -> Callable[[bytes], object]: ...
2525

2626
WSGIEnvironment: TypeAlias = dict[str, Any] # stable

stdlib/bdb.pyi

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import ExcInfo
12
from collections.abc import Callable, Iterable, Mapping
23
from types import CodeType, FrameType, TracebackType
34
from typing import IO, Any, SupportsInt, TypeVar
@@ -8,14 +9,12 @@ __all__ = ["BdbQuit", "Bdb", "Breakpoint"]
89
_T = TypeVar("_T")
910
_P = ParamSpec("_P")
1011
_TraceDispatch: TypeAlias = Callable[[FrameType, str, Any], Any] # TODO: Recursive type
11-
_ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, FrameType]
1212

1313
GENERATOR_AND_COROUTINE_FLAGS: Literal[672]
1414

1515
class BdbQuit(Exception): ...
1616

1717
class Bdb:
18-
1918
skip: set[str] | None
2019
breaks: dict[str, list[int]]
2120
fncache: dict[str, str]
@@ -32,7 +31,7 @@ class Bdb:
3231
def dispatch_line(self, frame: FrameType) -> _TraceDispatch: ...
3332
def dispatch_call(self, frame: FrameType, arg: None) -> _TraceDispatch: ...
3433
def dispatch_return(self, frame: FrameType, arg: Any) -> _TraceDispatch: ...
35-
def dispatch_exception(self, frame: FrameType, arg: _ExcInfo) -> _TraceDispatch: ...
34+
def dispatch_exception(self, frame: FrameType, arg: ExcInfo) -> _TraceDispatch: ...
3635
def is_skipped_module(self, module_name: str) -> bool: ...
3736
def stop_here(self, frame: FrameType) -> bool: ...
3837
def break_here(self, frame: FrameType) -> bool: ...
@@ -41,7 +40,7 @@ class Bdb:
4140
def user_call(self, frame: FrameType, argument_list: None) -> None: ...
4241
def user_line(self, frame: FrameType) -> None: ...
4342
def user_return(self, frame: FrameType, return_value: Any) -> None: ...
44-
def user_exception(self, frame: FrameType, exc_info: _ExcInfo) -> None: ...
43+
def user_exception(self, frame: FrameType, exc_info: ExcInfo) -> None: ...
4544
def set_until(self, frame: FrameType, lineno: int | None = ...) -> None: ...
4645
def set_step(self) -> None: ...
4746
def set_next(self, frame: FrameType) -> None: ...

stdlib/cgitb.pyi

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
from _typeshed import StrOrBytesPath
1+
from _typeshed import OptExcInfo, StrOrBytesPath
22
from collections.abc import Callable
33
from types import FrameType, TracebackType
44
from typing import IO, Any
5-
from typing_extensions import TypeAlias
6-
7-
_ExcInfo: TypeAlias = tuple[type[BaseException] | None, BaseException | None, TracebackType | None]
85

96
__UNDEF__: object # undocumented sentinel
107

@@ -16,8 +13,8 @@ def lookup(name: str, frame: FrameType, locals: dict[str, Any]) -> tuple[str | N
1613
def scanvars(
1714
reader: Callable[[], bytes], frame: FrameType, locals: dict[str, Any]
1815
) -> list[tuple[str, str | None, Any]]: ... # undocumented
19-
def html(einfo: _ExcInfo, context: int = ...) -> str: ...
20-
def text(einfo: _ExcInfo, context: int = ...) -> str: ...
16+
def html(einfo: OptExcInfo, context: int = ...) -> str: ...
17+
def text(einfo: OptExcInfo, context: int = ...) -> str: ...
2118

2219
class Hook: # undocumented
2320
def __init__(
@@ -29,7 +26,7 @@ class Hook: # undocumented
2926
format: str = ...,
3027
) -> None: ...
3128
def __call__(self, etype: type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None) -> None: ...
32-
def handle(self, info: _ExcInfo | None = ...) -> None: ...
29+
def handle(self, info: OptExcInfo | None = ...) -> None: ...
3330

34-
def handler(info: _ExcInfo | None = ...) -> None: ...
31+
def handler(info: OptExcInfo | None = ...) -> None: ...
3532
def enable(display: int = ..., logdir: StrOrBytesPath | None = ..., context: int = ..., format: str = ...) -> None: ...

stdlib/doctest.pyi

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import types
22
import unittest
3+
from _typeshed import ExcInfo
34
from collections.abc import Callable
45
from typing import Any, NamedTuple
56
from typing_extensions import TypeAlias
@@ -126,7 +127,6 @@ class DocTestFinder:
126127
) -> list[DocTest]: ...
127128

128129
_Out: TypeAlias = Callable[[str], Any]
129-
_ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, types.TracebackType]
130130

131131
class DocTestRunner:
132132
DIVIDER: str
@@ -139,7 +139,7 @@ class DocTestRunner:
139139
def report_start(self, out: _Out, test: DocTest, example: Example) -> None: ...
140140
def report_success(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ...
141141
def report_failure(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ...
142-
def report_unexpected_exception(self, out: _Out, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ...
142+
def report_unexpected_exception(self, out: _Out, test: DocTest, example: Example, exc_info: ExcInfo) -> None: ...
143143
def run(
144144
self, test: DocTest, compileflags: int | None = ..., out: _Out | None = ..., clear_globs: bool = ...
145145
) -> TestResults: ...
@@ -159,8 +159,8 @@ class DocTestFailure(Exception):
159159
class UnexpectedException(Exception):
160160
test: DocTest
161161
example: Example
162-
exc_info: _ExcInfo
163-
def __init__(self, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ...
162+
exc_info: ExcInfo
163+
def __init__(self, test: DocTest, example: Example, exc_info: ExcInfo) -> None: ...
164164

165165
class DebugRunner(DocTestRunner): ...
166166

stdlib/sys.pyi

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import sys
2-
from _typeshed import structseq
2+
from _typeshed import OptExcInfo, structseq
33
from builtins import object as _object
44
from collections.abc import AsyncGenerator, Callable, Coroutine, Sequence
55
from importlib.abc import PathEntryFinder
66
from importlib.machinery import ModuleSpec
77
from io import TextIOWrapper
88
from types import FrameType, ModuleType, TracebackType
9-
from typing import Any, NoReturn, Protocol, TextIO, TypeVar, Union, overload
9+
from typing import Any, NoReturn, Protocol, TextIO, TypeVar, overload
1010
from typing_extensions import Literal, TypeAlias, final
1111

1212
_T = TypeVar("_T")
1313

14-
# The following type alias are stub-only and do not exist during runtime
15-
_ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType]
16-
_OptExcInfo: TypeAlias = Union[_ExcInfo, tuple[None, None, None]]
14+
_OptExcInfo: TypeAlias = OptExcInfo # TODO: obsolete, remove fall 2022 or later
1715

1816
# Intentionally omits one deprecated and one optional method of `importlib.abc.MetaPathFinder`
1917
class _MetaPathFinder(Protocol):
@@ -218,7 +216,7 @@ def _getframe(__depth: int = ...) -> FrameType: ...
218216
def _debugmallocstats() -> None: ...
219217
def __displayhook__(__value: object) -> None: ...
220218
def __excepthook__(__exctype: type[BaseException], __value: BaseException, __traceback: TracebackType | None) -> None: ...
221-
def exc_info() -> _OptExcInfo: ...
219+
def exc_info() -> OptExcInfo: ...
222220

223221
# sys.exit() accepts an optional argument of anything printable
224222
def exit(__status: object = ...) -> NoReturn: ...

stdlib/wsgiref/handlers.pyi

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1+
from _typeshed import OptExcInfo
12
from _typeshed.wsgi import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment
23
from abc import abstractmethod
34
from collections.abc import Callable, MutableMapping
4-
from types import TracebackType
55
from typing import IO
6-
from typing_extensions import TypeAlias
76

87
from .headers import Headers
98
from .util import FileWrapper
109

1110
__all__ = ["BaseHandler", "SimpleHandler", "BaseCGIHandler", "CGIHandler", "IISCGIHandler", "read_environ"]
1211

13-
_exc_info: TypeAlias = tuple[type[BaseException] | None, BaseException | None, TracebackType | None]
14-
1512
def format_date_time(timestamp: float | None) -> str: ... # undocumented
1613
def read_environ() -> dict[str, str]: ...
1714

@@ -41,7 +38,7 @@ class BaseHandler:
4138
def set_content_length(self) -> None: ...
4239
def cleanup_headers(self) -> None: ...
4340
def start_response(
44-
self, status: str, headers: list[tuple[str, str]], exc_info: _exc_info | None = ...
41+
self, status: str, headers: list[tuple[str, str]], exc_info: OptExcInfo | None = ...
4542
) -> Callable[[bytes], None]: ...
4643
def send_preamble(self) -> None: ...
4744
def write(self, data: bytes) -> None: ...
@@ -51,7 +48,7 @@ class BaseHandler:
5148
def send_headers(self) -> None: ...
5249
def result_is_file(self) -> bool: ...
5350
def client_is_modern(self) -> bool: ...
54-
def log_exception(self, exc_info: _exc_info) -> None: ...
51+
def log_exception(self, exc_info: OptExcInfo) -> None: ...
5552
def handle_error(self) -> None: ...
5653
def error_output(self, environ: WSGIEnvironment, start_response: StartResponse) -> list[bytes]: ...
5754
@abstractmethod

0 commit comments

Comments
 (0)