Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big diff: Use new "|" union syntax #5872

Merged
merged 15 commits into from
Aug 8, 2021
  •  
  •  
  •  
28 changes: 9 additions & 19 deletions stdlib/_bisect.pyi
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
import sys
from _typeshed import SupportsLessThan
from typing import Callable, MutableSequence, Optional, Sequence, TypeVar
from typing import Callable, MutableSequence, Sequence, TypeVar

_T = TypeVar("_T")

if sys.version_info >= (3, 10):
def bisect_left(
a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ...
a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ...
) -> int: ...
def bisect_right(
a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ...
a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ...
) -> int: ...
def insort_left(
a: MutableSequence[_T],
x: _T,
lo: int = ...,
hi: Optional[int] = ...,
*,
key: Optional[Callable[[_T], SupportsLessThan]] = ...,
a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ...
) -> None: ...
def insort_right(
a: MutableSequence[_T],
x: _T,
lo: int = ...,
hi: Optional[int] = ...,
*,
key: Optional[Callable[[_T], SupportsLessThan]] = ...,
a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ...
) -> None: ...

else:
def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ...
def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ...
def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ...
def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ...
def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> int: ...
def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> int: ...
def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> None: ...
def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> None: ...
86 changes: 42 additions & 44 deletions stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import codecs
import sys
from typing import Any, Callable, Dict, Optional, Tuple, Union
from typing import Any, Callable, Dict, Tuple, Union

# This type is not exposed; it is defined in unicodeobject.c
class _EncodingMap:
Expand All @@ -13,56 +13,54 @@ def register(__search_function: Callable[[str], Any]) -> None: ...
def register_error(__errors: str, __handler: _Handler) -> None: ...
def lookup(__encoding: str) -> codecs.CodecInfo: ...
def lookup_error(__name: str) -> _Handler: ...
def decode(obj: Any, encoding: str = ..., errors: Optional[str] = ...) -> Any: ...
def encode(obj: Any, encoding: str = ..., errors: Optional[str] = ...) -> Any: ...
def decode(obj: Any, encoding: str = ..., errors: str | None = ...) -> Any: ...
def encode(obj: Any, encoding: str = ..., errors: str | None = ...) -> Any: ...
def charmap_build(__map: str) -> _MapT: ...
def ascii_decode(__data: bytes, __errors: Optional[str] = ...) -> Tuple[str, int]: ...
def ascii_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def charmap_decode(__data: bytes, __errors: Optional[str] = ..., __mapping: Optional[_MapT] = ...) -> Tuple[str, int]: ...
def charmap_encode(__str: str, __errors: Optional[str] = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ...
def escape_decode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ...
def escape_encode(__data: bytes, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def latin_1_decode(__data: bytes, __errors: Optional[str] = ...) -> Tuple[str, int]: ...
def latin_1_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def raw_unicode_escape_decode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ...
def raw_unicode_escape_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def readbuffer_encode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def unicode_escape_decode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ...
def unicode_escape_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def ascii_decode(__data: bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
def ascii_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def charmap_decode(__data: bytes, __errors: str | None = ..., __mapping: _MapT | None = ...) -> Tuple[str, int]: ...
def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _MapT | None = ...) -> Tuple[bytes, int]: ...
def escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
def escape_encode(__data: bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def latin_1_decode(__data: bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
def latin_1_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def raw_unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
def raw_unicode_escape_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def readbuffer_encode(__data: str | bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ...
def unicode_escape_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...

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

def utf_16_be_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_16_be_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def utf_16_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_16_encode(__str: str, __errors: Optional[str] = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
def utf_16_be_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_16_be_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def utf_16_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_16_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
def utf_16_ex_decode(
__data: bytes, __errors: Optional[str] = ..., __byteorder: int = ..., __final: int = ...
__data: bytes, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
) -> Tuple[str, int, int]: ...
def utf_16_le_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_16_le_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def utf_32_be_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_32_be_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def utf_32_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_32_encode(__str: str, __errors: Optional[str] = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
def utf_16_le_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_16_le_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def utf_32_be_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_32_be_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def utf_32_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_32_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
def utf_32_ex_decode(
__data: bytes, __errors: Optional[str] = ..., __byteorder: int = ..., __final: int = ...
__data: bytes, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
) -> Tuple[str, int, int]: ...
def utf_32_le_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_32_le_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def utf_7_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_7_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def utf_8_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_8_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def utf_32_le_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_32_le_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def utf_7_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_7_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def utf_8_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def utf_8_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...

if sys.platform == "win32":
def mbcs_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
def mbcs_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def code_page_decode(
__codepage: int, __data: bytes, __errors: Optional[str] = ..., __final: int = ...
) -> Tuple[str, int]: ...
def code_page_encode(__code_page: int, __str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def oem_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ...
def oem_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ...
def mbcs_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def mbcs_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def code_page_decode(__codepage: int, __data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
def oem_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ...
def oem_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ...
4 changes: 2 additions & 2 deletions stdlib/_compression.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from _typeshed import WriteableBuffer
from io import BufferedIOBase, RawIOBase
from typing import Any, Callable, Protocol, Tuple, Type, Union
from typing import Any, Callable, Protocol, Tuple, Type

BUFFER_SIZE: Any

Expand All @@ -16,7 +16,7 @@ class DecompressReader(RawIOBase):
self,
fp: _Reader,
decomp_factory: Callable[..., object],
trailing_error: Union[Type[Exception], Tuple[Type[Exception], ...]] = ...,
trailing_error: Type[Exception] | Tuple[Type[Exception], ...] = ...,
**decomp_args: Any,
) -> None: ...
def readable(self) -> bool: ...
Expand Down
6 changes: 3 additions & 3 deletions stdlib/_csv.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Iterable, Iterator, List, Optional, Protocol, Type, Union
from typing import Any, Iterable, Iterator, List, Protocol, Type, Union

QUOTE_ALL: int
QUOTE_MINIMAL: int
Expand All @@ -9,8 +9,8 @@ class Error(Exception): ...

class Dialect:
delimiter: str
quotechar: Optional[str]
escapechar: Optional[str]
quotechar: str | None
escapechar: str | None
doublequote: bool
skipinitialspace: bool
lineterminator: str
Expand Down
10 changes: 5 additions & 5 deletions stdlib/_curses.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import IO, Any, BinaryIO, NamedTuple, Optional, Tuple, Union, overload
from typing import IO, Any, BinaryIO, NamedTuple, Tuple, Union, overload

_chtype = Union[str, bytes, int]

Expand Down Expand Up @@ -338,7 +338,7 @@ def resize_term(__nlines: int, __ncols: int) -> None: ...
def resizeterm(__nlines: int, __ncols: int) -> None: ...
def savetty() -> None: ...
def setsyx(__y: int, __x: int) -> None: ...
def setupterm(term: Optional[str] = ..., fd: int = ...) -> None: ...
def setupterm(term: str | None = ..., fd: int = ...) -> None: ...
def start_color() -> None: ...
def termattrs() -> int: ...
def termname() -> bytes: ...
Expand All @@ -359,7 +359,7 @@ def tparm(
) -> bytes: ...
def typeahead(__fd: int) -> None: ...
def unctrl(__ch: _chtype) -> bytes: ...
def unget_wch(__ch: Union[int, str]) -> None: ...
def unget_wch(__ch: int | str) -> None: ...
def ungetch(__ch: _chtype) -> None: ...
def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ...
def update_lines_cols() -> int: ...
Expand Down Expand Up @@ -434,9 +434,9 @@ class _CursesWindow:
@overload
def getch(self, y: int, x: int) -> int: ...
@overload
def get_wch(self) -> Union[int, str]: ...
def get_wch(self) -> int | str: ...
@overload
def get_wch(self, y: int, x: int) -> Union[int, str]: ...
def get_wch(self, y: int, x: int) -> int | str: ...
@overload
def getkey(self) -> str: ...
@overload
Expand Down
8 changes: 4 additions & 4 deletions stdlib/_dummy_thread.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, NoReturn, Optional, Tuple
from typing import Any, Callable, Dict, NoReturn, Tuple

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

class LockType(object):
locked_status: bool
def __init__(self) -> None: ...
def acquire(self, waitflag: Optional[bool] = ..., timeout: int = ...) -> bool: ...
def __enter__(self, waitflag: Optional[bool] = ..., timeout: int = ...) -> bool: ...
def acquire(self, waitflag: bool | None = ..., timeout: int = ...) -> bool: ...
def __enter__(self, waitflag: bool | None = ..., timeout: int = ...) -> bool: ...
def __exit__(self, typ: Any, val: Any, tb: Any) -> None: ...
def release(self) -> bool: ...
def locked(self) -> bool: ...
Expand Down
Loading