Skip to content

Commit ee48730

Browse files
authored
Big diff: Use new "|" union syntax (#5872)
1 parent b9adb7a commit ee48730

578 files changed

Lines changed: 8079 additions & 8965 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

stdlib/_bisect.pyi

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
11
import sys
22
from _typeshed import SupportsLessThan
3-
from typing import Callable, MutableSequence, Optional, Sequence, TypeVar
3+
from typing import Callable, MutableSequence, Sequence, TypeVar
44

55
_T = TypeVar("_T")
66

77
if sys.version_info >= (3, 10):
88
def bisect_left(
9-
a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ...
9+
a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ...
1010
) -> int: ...
1111
def bisect_right(
12-
a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ...
12+
a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ...
1313
) -> int: ...
1414
def insort_left(
15-
a: MutableSequence[_T],
16-
x: _T,
17-
lo: int = ...,
18-
hi: Optional[int] = ...,
19-
*,
20-
key: Optional[Callable[[_T], SupportsLessThan]] = ...,
15+
a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ...
2116
) -> None: ...
2217
def insort_right(
23-
a: MutableSequence[_T],
24-
x: _T,
25-
lo: int = ...,
26-
hi: Optional[int] = ...,
27-
*,
28-
key: Optional[Callable[[_T], SupportsLessThan]] = ...,
18+
a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ...
2919
) -> None: ...
3020

3121
else:
32-
def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ...
33-
def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ...
34-
def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ...
35-
def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ...
22+
def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> int: ...
23+
def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> int: ...
24+
def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> None: ...
25+
def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> None: ...

stdlib/_codecs.pyi

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import codecs
22
import sys
3-
from typing import Any, Callable, Dict, Optional, Tuple, Union
3+
from typing import Any, Callable, Dict, Tuple, Union
44

55
# This type is not exposed; it is defined in unicodeobject.c
66
class _EncodingMap:
@@ -13,56 +13,54 @@ def register(__search_function: Callable[[str], Any]) -> None: ...
1313
def register_error(__errors: str, __handler: _Handler) -> None: ...
1414
def lookup(__encoding: str) -> codecs.CodecInfo: ...
1515
def lookup_error(__name: str) -> _Handler: ...
16-
def decode(obj: Any, encoding: str = ..., errors: Optional[str] = ...) -> Any: ...
17-
def encode(obj: Any, encoding: str = ..., errors: Optional[str] = ...) -> Any: ...
16+
def decode(obj: Any, encoding: str = ..., errors: str | None = ...) -> Any: ...
17+
def encode(obj: Any, encoding: str = ..., errors: str | None = ...) -> Any: ...
1818
def charmap_build(__map: str) -> _MapT: ...
19-
def ascii_decode(__data: bytes, __errors: Optional[str] = ...) -> Tuple[str, int]: ...
20-
def ascii_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
21-
def charmap_decode(__data: bytes, __errors: Optional[str] = ..., __mapping: Optional[_MapT] = ...) -> Tuple[str, int]: ...
22-
def charmap_encode(__str: str, __errors: Optional[str] = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ...
23-
def escape_decode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ...
24-
def escape_encode(__data: bytes, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
25-
def latin_1_decode(__data: bytes, __errors: Optional[str] = ...) -> Tuple[str, int]: ...
26-
def latin_1_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
27-
def raw_unicode_escape_decode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ...
28-
def raw_unicode_escape_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
29-
def readbuffer_encode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
30-
def unicode_escape_decode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ...
31-
def unicode_escape_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
19+
def ascii_decode(__data: bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
20+
def ascii_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
21+
def charmap_decode(__data: bytes, __errors: str | None = ..., __mapping: _MapT | None = ...) -> Tuple[str, int]: ...
22+
def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _MapT | None = ...) -> Tuple[bytes, int]: ...
23+
def escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
24+
def escape_encode(__data: bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ...
25+
def latin_1_decode(__data: bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
26+
def latin_1_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
27+
def raw_unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
28+
def raw_unicode_escape_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
29+
def readbuffer_encode(__data: str | bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ...
30+
def unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
31+
def unicode_escape_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
3232

3333
if sys.version_info < (3, 8):
34-
def unicode_internal_decode(__obj: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ...
35-
def unicode_internal_encode(__obj: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
34+
def unicode_internal_decode(__obj: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
35+
def unicode_internal_encode(__obj: str | bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ...
3636

37-
def utf_16_be_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
38-
def utf_16_be_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
39-
def utf_16_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
40-
def utf_16_encode(__str: str, __errors: Optional[str] = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
37+
def utf_16_be_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
38+
def utf_16_be_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
39+
def utf_16_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
40+
def utf_16_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
4141
def utf_16_ex_decode(
42-
__data: bytes, __errors: Optional[str] = ..., __byteorder: int = ..., __final: int = ...
42+
__data: bytes, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
4343
) -> Tuple[str, int, int]: ...
44-
def utf_16_le_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
45-
def utf_16_le_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
46-
def utf_32_be_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
47-
def utf_32_be_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
48-
def utf_32_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
49-
def utf_32_encode(__str: str, __errors: Optional[str] = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
44+
def utf_16_le_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
45+
def utf_16_le_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
46+
def utf_32_be_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
47+
def utf_32_be_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
48+
def utf_32_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
49+
def utf_32_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
5050
def utf_32_ex_decode(
51-
__data: bytes, __errors: Optional[str] = ..., __byteorder: int = ..., __final: int = ...
51+
__data: bytes, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
5252
) -> Tuple[str, int, int]: ...
53-
def utf_32_le_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
54-
def utf_32_le_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
55-
def utf_7_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
56-
def utf_7_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
57-
def utf_8_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
58-
def utf_8_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
53+
def utf_32_le_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
54+
def utf_32_le_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
55+
def utf_7_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
56+
def utf_7_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
57+
def utf_8_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
58+
def utf_8_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
5959

6060
if sys.platform == "win32":
61-
def mbcs_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
62-
def mbcs_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
63-
def code_page_decode(
64-
__codepage: int, __data: bytes, __errors: Optional[str] = ..., __final: int = ...
65-
) -> Tuple[str, int]: ...
66-
def code_page_encode(__code_page: int, __str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
67-
def oem_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
68-
def oem_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
61+
def mbcs_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
62+
def mbcs_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
63+
def code_page_decode(__codepage: int, __data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
64+
def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
65+
def oem_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
66+
def oem_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...

stdlib/_compression.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import WriteableBuffer
22
from io import BufferedIOBase, RawIOBase
3-
from typing import Any, Callable, Protocol, Tuple, Type, Union
3+
from typing import Any, Callable, Protocol, Tuple, Type
44

55
BUFFER_SIZE: Any
66

@@ -16,7 +16,7 @@ class DecompressReader(RawIOBase):
1616
self,
1717
fp: _Reader,
1818
decomp_factory: Callable[..., object],
19-
trailing_error: Union[Type[Exception], Tuple[Type[Exception], ...]] = ...,
19+
trailing_error: Type[Exception] | Tuple[Type[Exception], ...] = ...,
2020
**decomp_args: Any,
2121
) -> None: ...
2222
def readable(self) -> bool: ...

stdlib/_csv.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Iterable, Iterator, List, Optional, Protocol, Type, Union
1+
from typing import Any, Iterable, Iterator, List, Protocol, Type, Union
22

33
QUOTE_ALL: int
44
QUOTE_MINIMAL: int
@@ -9,8 +9,8 @@ class Error(Exception): ...
99

1010
class Dialect:
1111
delimiter: str
12-
quotechar: Optional[str]
13-
escapechar: Optional[str]
12+
quotechar: str | None
13+
escapechar: str | None
1414
doublequote: bool
1515
skipinitialspace: bool
1616
lineterminator: str

stdlib/_curses.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from typing import IO, Any, BinaryIO, NamedTuple, Optional, Tuple, Union, overload
2+
from typing import IO, Any, BinaryIO, NamedTuple, Tuple, Union, overload
33

44
_chtype = Union[str, bytes, int]
55

@@ -338,7 +338,7 @@ def resize_term(__nlines: int, __ncols: int) -> None: ...
338338
def resizeterm(__nlines: int, __ncols: int) -> None: ...
339339
def savetty() -> None: ...
340340
def setsyx(__y: int, __x: int) -> None: ...
341-
def setupterm(term: Optional[str] = ..., fd: int = ...) -> None: ...
341+
def setupterm(term: str | None = ..., fd: int = ...) -> None: ...
342342
def start_color() -> None: ...
343343
def termattrs() -> int: ...
344344
def termname() -> bytes: ...
@@ -359,7 +359,7 @@ def tparm(
359359
) -> bytes: ...
360360
def typeahead(__fd: int) -> None: ...
361361
def unctrl(__ch: _chtype) -> bytes: ...
362-
def unget_wch(__ch: Union[int, str]) -> None: ...
362+
def unget_wch(__ch: int | str) -> None: ...
363363
def ungetch(__ch: _chtype) -> None: ...
364364
def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ...
365365
def update_lines_cols() -> int: ...
@@ -434,9 +434,9 @@ class _CursesWindow:
434434
@overload
435435
def getch(self, y: int, x: int) -> int: ...
436436
@overload
437-
def get_wch(self) -> Union[int, str]: ...
437+
def get_wch(self) -> int | str: ...
438438
@overload
439-
def get_wch(self, y: int, x: int) -> Union[int, str]: ...
439+
def get_wch(self, y: int, x: int) -> int | str: ...
440440
@overload
441441
def getkey(self) -> str: ...
442442
@overload

stdlib/_dummy_thread.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable, Dict, NoReturn, Optional, Tuple
1+
from typing import Any, Callable, Dict, NoReturn, Tuple
22

33
TIMEOUT_MAX: int
44
error = RuntimeError
@@ -7,13 +7,13 @@ def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs
77
def exit() -> NoReturn: ...
88
def get_ident() -> int: ...
99
def allocate_lock() -> LockType: ...
10-
def stack_size(size: Optional[int] = ...) -> int: ...
10+
def stack_size(size: int | None = ...) -> int: ...
1111

1212
class LockType(object):
1313
locked_status: bool
1414
def __init__(self) -> None: ...
15-
def acquire(self, waitflag: Optional[bool] = ..., timeout: int = ...) -> bool: ...
16-
def __enter__(self, waitflag: Optional[bool] = ..., timeout: int = ...) -> bool: ...
15+
def acquire(self, waitflag: bool | None = ..., timeout: int = ...) -> bool: ...
16+
def __enter__(self, waitflag: bool | None = ..., timeout: int = ...) -> bool: ...
1717
def __exit__(self, typ: Any, val: Any, tb: Any) -> None: ...
1818
def release(self) -> bool: ...
1919
def locked(self) -> bool: ...

0 commit comments

Comments
 (0)