Skip to content

Commit 3f8ada0

Browse files
authored
Sync typeshed (#11035)
Source commit: python/typeshed@8e0e13a Co-authored-by: hauntsaninja <>
1 parent 56b6803 commit 3f8ada0

File tree

598 files changed

+9364
-10148
lines changed

Some content is hidden

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

598 files changed

+9364
-10148
lines changed

mypy/typeshed/stdlib/@python2/BaseHTTPServer.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import mimetools
22
import SocketServer
3-
from typing import Any, BinaryIO, Callable, Mapping, Optional, Tuple, Union
3+
from typing import Any, BinaryIO, Callable, Mapping, Tuple
44

55
class HTTPServer(SocketServer.TCPServer):
66
server_name: str
@@ -27,15 +27,15 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
2727
def __init__(self, request: bytes, client_address: Tuple[str, int], server: SocketServer.BaseServer) -> None: ...
2828
def handle(self) -> None: ...
2929
def handle_one_request(self) -> None: ...
30-
def send_error(self, code: int, message: Optional[str] = ...) -> None: ...
31-
def send_response(self, code: int, message: Optional[str] = ...) -> None: ...
30+
def send_error(self, code: int, message: str | None = ...) -> None: ...
31+
def send_response(self, code: int, message: str | None = ...) -> None: ...
3232
def send_header(self, keyword: str, value: str) -> None: ...
3333
def end_headers(self) -> None: ...
3434
def flush_headers(self) -> None: ...
35-
def log_request(self, code: Union[int, str] = ..., size: Union[int, str] = ...) -> None: ...
35+
def log_request(self, code: int | str = ..., size: int | str = ...) -> None: ...
3636
def log_error(self, format: str, *args: Any) -> None: ...
3737
def log_message(self, format: str, *args: Any) -> None: ...
3838
def version_string(self) -> str: ...
39-
def date_time_string(self, timestamp: Optional[int] = ...) -> str: ...
39+
def date_time_string(self, timestamp: int | None = ...) -> str: ...
4040
def log_date_time_string(self) -> str: ...
4141
def address_string(self) -> str: ...

mypy/typeshed/stdlib/@python2/ConfigParser.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed import SupportsNoArgReadline
2-
from typing import IO, Any, Dict, List, Optional, Sequence, Tuple, Union
2+
from typing import IO, Any, Dict, List, Sequence, Tuple
33

44
DEFAULTSECT: str
55
MAX_INTERPOLATION_DEPTH: int
@@ -65,7 +65,7 @@ class RawConfigParser:
6565
def add_section(self, section: str) -> None: ...
6666
def has_section(self, section: str) -> bool: ...
6767
def options(self, section: str) -> List[str]: ...
68-
def read(self, filenames: Union[str, Sequence[str]]) -> List[str]: ...
68+
def read(self, filenames: str | Sequence[str]) -> List[str]: ...
6969
def readfp(self, fp: SupportsNoArgReadline[str], filename: str = ...) -> None: ...
7070
def get(self, section: str, option: str) -> str: ...
7171
def items(self, section: str) -> List[Tuple[Any, Any]]: ...
@@ -84,8 +84,8 @@ class RawConfigParser:
8484

8585
class ConfigParser(RawConfigParser):
8686
_KEYCRE: Any
87-
def get(self, section: str, option: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> Any: ...
88-
def items(self, section: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> List[Tuple[str, Any]]: ...
87+
def get(self, section: str, option: str, raw: bool = ..., vars: Dict[Any, Any] | None = ...) -> Any: ...
88+
def items(self, section: str, raw: bool = ..., vars: Dict[Any, Any] | None = ...) -> List[Tuple[str, Any]]: ...
8989
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
9090
def _interpolation_replace(self, match: Any) -> str: ...
9191

mypy/typeshed/stdlib/@python2/Cookie.pyi

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

33
class CookieError(Exception): ...
44

@@ -10,30 +10,30 @@ class Morsel(Dict[Any, Any]):
1010
value: Any
1111
coded_value: Any
1212
def set(self, key, val, coded_val, LegalChars=..., idmap=..., translate=...): ...
13-
def output(self, attrs: Optional[Any] = ..., header=...): ...
14-
def js_output(self, attrs: Optional[Any] = ...): ...
15-
def OutputString(self, attrs: Optional[Any] = ...): ...
13+
def output(self, attrs: Any | None = ..., header=...): ...
14+
def js_output(self, attrs: Any | None = ...): ...
15+
def OutputString(self, attrs: Any | None = ...): ...
1616

1717
class BaseCookie(Dict[Any, Any]):
1818
def value_decode(self, val): ...
1919
def value_encode(self, val): ...
20-
def __init__(self, input: Optional[Any] = ...): ...
20+
def __init__(self, input: Any | None = ...): ...
2121
def __setitem__(self, key, value): ...
22-
def output(self, attrs: Optional[Any] = ..., header=..., sep=...): ...
23-
def js_output(self, attrs: Optional[Any] = ...): ...
22+
def output(self, attrs: Any | None = ..., header=..., sep=...): ...
23+
def js_output(self, attrs: Any | None = ...): ...
2424
def load(self, rawdata): ...
2525

2626
class SimpleCookie(BaseCookie):
2727
def value_decode(self, val): ...
2828
def value_encode(self, val): ...
2929

3030
class SerialCookie(BaseCookie):
31-
def __init__(self, input: Optional[Any] = ...): ...
31+
def __init__(self, input: Any | None = ...): ...
3232
def value_decode(self, val): ...
3333
def value_encode(self, val): ...
3434

3535
class SmartCookie(BaseCookie):
36-
def __init__(self, input: Optional[Any] = ...): ...
36+
def __init__(self, input: Any | None = ...): ...
3737
def value_decode(self, val): ...
3838
def value_encode(self, val): ...
3939

mypy/typeshed/stdlib/@python2/Queue.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Deque, Generic, Optional, TypeVar
1+
from typing import Any, Deque, Generic, TypeVar
22

33
_T = TypeVar("_T")
44

@@ -19,9 +19,9 @@ class Queue(Generic[_T]):
1919
def qsize(self) -> int: ...
2020
def empty(self) -> bool: ...
2121
def full(self) -> bool: ...
22-
def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ...
22+
def put(self, item: _T, block: bool = ..., timeout: float | None = ...) -> None: ...
2323
def put_nowait(self, item: _T) -> None: ...
24-
def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ...
24+
def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ...
2525
def get_nowait(self) -> _T: ...
2626

2727
class PriorityQueue(Queue[_T]): ...
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import BaseHTTPServer
22
from StringIO import StringIO
3-
from typing import IO, Any, AnyStr, Mapping, Optional, Union
3+
from typing import IO, Any, AnyStr, Mapping
44

55
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
66
server_version: str
77
def do_GET(self) -> None: ...
88
def do_HEAD(self) -> None: ...
9-
def send_head(self) -> Optional[IO[str]]: ...
10-
def list_directory(self, path: Union[str, unicode]) -> Optional[StringIO[Any]]: ...
9+
def send_head(self) -> IO[str] | None: ...
10+
def list_directory(self, path: str | unicode) -> StringIO[Any] | None: ...
1111
def translate_path(self, path: AnyStr) -> AnyStr: ...
1212
def copyfile(self, source: IO[AnyStr], outputfile: IO[AnyStr]): ...
13-
def guess_type(self, path: Union[str, unicode]) -> str: ...
13+
def guess_type(self, path: str | unicode) -> str: ...
1414
extensions_map: Mapping[str, str]

mypy/typeshed/stdlib/@python2/SocketServer.pyi

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from socket import SocketType
3-
from typing import Any, BinaryIO, Callable, ClassVar, List, Optional, Text, Tuple, Union
3+
from typing import Any, BinaryIO, Callable, ClassVar, List, Text, Tuple, Union
44

55
class BaseServer:
66
address_family: int
@@ -10,7 +10,7 @@ class BaseServer:
1010
allow_reuse_address: bool
1111
request_queue_size: int
1212
socket_type: int
13-
timeout: Optional[float]
13+
timeout: float | None
1414
def __init__(self, server_address: Any, RequestHandlerClass: Callable[..., BaseRequestHandler]) -> None: ...
1515
def fileno(self) -> int: ...
1616
def handle_request(self) -> None: ...
@@ -46,22 +46,22 @@ if sys.platform != "win32":
4646
class UnixStreamServer(BaseServer):
4747
def __init__(
4848
self,
49-
server_address: Union[Text, bytes],
49+
server_address: Text | bytes,
5050
RequestHandlerClass: Callable[..., BaseRequestHandler],
5151
bind_and_activate: bool = ...,
5252
) -> None: ...
5353
class UnixDatagramServer(BaseServer):
5454
def __init__(
5555
self,
56-
server_address: Union[Text, bytes],
56+
server_address: Text | bytes,
5757
RequestHandlerClass: Callable[..., BaseRequestHandler],
5858
bind_and_activate: bool = ...,
5959
) -> None: ...
6060

6161
if sys.platform != "win32":
6262
class ForkingMixIn:
63-
timeout: Optional[float] # undocumented
64-
active_children: Optional[List[int]] # undocumented
63+
timeout: float | None # undocumented
64+
active_children: List[int] | None # undocumented
6565
max_children: int # undocumented
6666
def collect_children(self) -> None: ... # undocumented
6767
def handle_timeout(self) -> None: ... # undocumented
@@ -99,16 +99,16 @@ class BaseRequestHandler:
9999
def finish(self) -> None: ...
100100

101101
class StreamRequestHandler(BaseRequestHandler):
102-
rbufsize: ClassVar[int] # Undocumented
103-
wbufsize: ClassVar[int] # Undocumented
104-
timeout: ClassVar[Optional[float]] # Undocumented
105-
disable_nagle_algorithm: ClassVar[bool] # Undocumented
106-
connection: SocketType # Undocumented
102+
rbufsize: ClassVar[int] # undocumented
103+
wbufsize: ClassVar[int] # undocumented
104+
timeout: ClassVar[float | None] # undocumented
105+
disable_nagle_algorithm: ClassVar[bool] # undocumented
106+
connection: SocketType # undocumented
107107
rfile: BinaryIO
108108
wfile: BinaryIO
109109

110110
class DatagramRequestHandler(BaseRequestHandler):
111-
packet: SocketType # Undocumented
112-
socket: SocketType # Undocumented
111+
packet: SocketType # undocumented
112+
socket: SocketType # undocumented
113113
rfile: BinaryIO
114114
wfile: BinaryIO

mypy/typeshed/stdlib/@python2/StringIO.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Optional
1+
from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List
22

33
class StringIO(IO[AnyStr], Generic[AnyStr]):
44
closed: bool
@@ -15,7 +15,7 @@ class StringIO(IO[AnyStr], Generic[AnyStr]):
1515
def read(self, n: int = ...) -> AnyStr: ...
1616
def readline(self, length: int = ...) -> AnyStr: ...
1717
def readlines(self, sizehint: int = ...) -> List[AnyStr]: ...
18-
def truncate(self, size: Optional[int] = ...) -> int: ...
18+
def truncate(self, size: int | None = ...) -> int: ...
1919
def write(self, s: AnyStr) -> int: ...
2020
def writelines(self, iterable: Iterable[AnyStr]) -> None: ...
2121
def flush(self) -> None: ...

mypy/typeshed/stdlib/@python2/UserDict.pyi

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
1-
from typing import (
2-
Any,
3-
Container,
4-
Dict,
5-
Generic,
6-
Iterable,
7-
Iterator,
8-
List,
9-
Mapping,
10-
Optional,
11-
Sized,
12-
Tuple,
13-
TypeVar,
14-
Union,
15-
overload,
16-
)
1+
from typing import Any, Container, Dict, Generic, Iterable, Iterator, List, Mapping, Sized, Tuple, TypeVar, overload
172

183
_KT = TypeVar("_KT")
194
_VT = TypeVar("_VT")
@@ -33,9 +18,9 @@ class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]):
3318
# From typing.Mapping[_KT, _VT]
3419
# (can't inherit because of keys())
3520
@overload
36-
def get(self, k: _KT) -> Optional[_VT]: ...
21+
def get(self, k: _KT) -> _VT | None: ...
3722
@overload
38-
def get(self, k: _KT, default: Union[_VT, _T]) -> Union[_VT, _T]: ...
23+
def get(self, k: _KT, default: _VT | _T) -> _VT | _T: ...
3924
def values(self) -> List[_VT]: ...
4025
def items(self) -> List[Tuple[_KT, _VT]]: ...
4126
def iterkeys(self) -> Iterator[_KT]: ...

mypy/typeshed/stdlib/@python2/UserList.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Iterable, List, MutableSequence, TypeVar, Union, overload
1+
from typing import Iterable, List, MutableSequence, TypeVar, overload
22

33
_T = TypeVar("_T")
44
_S = TypeVar("_S")
@@ -10,7 +10,7 @@ class UserList(MutableSequence[_T]):
1010
def __setitem__(self, i: int, o: _T) -> None: ...
1111
@overload
1212
def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ...
13-
def __delitem__(self, i: Union[int, slice]) -> None: ...
13+
def __delitem__(self, i: int | slice) -> None: ...
1414
def __len__(self) -> int: ...
1515
@overload
1616
def __getitem__(self, i: int) -> _T: ...

mypy/typeshed/stdlib/@python2/UserString.pyi

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Iterable, List, MutableSequence, Optional, Sequence, Text, Tuple, TypeVar, Union, overload
1+
from typing import Any, Iterable, List, MutableSequence, Sequence, Text, Tuple, TypeVar, overload
22

33
_UST = TypeVar("_UST", bound=UserString)
44
_MST = TypeVar("_MST", bound=MutableString)
@@ -24,9 +24,9 @@ class UserString(Sequence[UserString]):
2424
def capitalize(self: _UST) -> _UST: ...
2525
def center(self: _UST, width: int, *args: Any) -> _UST: ...
2626
def count(self, sub: int, start: int = ..., end: int = ...) -> int: ...
27-
def decode(self: _UST, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UST: ...
28-
def encode(self: _UST, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UST: ...
29-
def endswith(self, suffix: Union[Text, Tuple[Text, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ...
27+
def decode(self: _UST, encoding: str | None = ..., errors: str | None = ...) -> _UST: ...
28+
def encode(self: _UST, encoding: str | None = ..., errors: str | None = ...) -> _UST: ...
29+
def endswith(self, suffix: Text | Tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
3030
def expandtabs(self: _UST, tabsize: int = ...) -> _UST: ...
3131
def find(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
3232
def index(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
@@ -42,19 +42,19 @@ class UserString(Sequence[UserString]):
4242
def join(self, seq: Iterable[Text]) -> Text: ...
4343
def ljust(self: _UST, width: int, *args: Any) -> _UST: ...
4444
def lower(self: _UST) -> _UST: ...
45-
def lstrip(self: _UST, chars: Optional[Text] = ...) -> _UST: ...
45+
def lstrip(self: _UST, chars: Text | None = ...) -> _UST: ...
4646
def partition(self, sep: Text) -> Tuple[Text, Text, Text]: ...
4747
def replace(self: _UST, old: Text, new: Text, maxsplit: int = ...) -> _UST: ...
4848
def rfind(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
4949
def rindex(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
5050
def rjust(self: _UST, width: int, *args: Any) -> _UST: ...
5151
def rpartition(self, sep: Text) -> Tuple[Text, Text, Text]: ...
52-
def rstrip(self: _UST, chars: Optional[Text] = ...) -> _UST: ...
53-
def split(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[Text]: ...
54-
def rsplit(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[Text]: ...
52+
def rstrip(self: _UST, chars: Text | None = ...) -> _UST: ...
53+
def split(self, sep: Text | None = ..., maxsplit: int = ...) -> List[Text]: ...
54+
def rsplit(self, sep: Text | None = ..., maxsplit: int = ...) -> List[Text]: ...
5555
def splitlines(self, keepends: int = ...) -> List[Text]: ...
56-
def startswith(self, prefix: Union[Text, Tuple[Text, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ...
57-
def strip(self: _UST, chars: Optional[Text] = ...) -> _UST: ...
56+
def startswith(self, prefix: Text | Tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
57+
def strip(self: _UST, chars: Text | None = ...) -> _UST: ...
5858
def swapcase(self: _UST) -> _UST: ...
5959
def title(self: _UST) -> _UST: ...
6060
def translate(self: _UST, *args: Any) -> _UST: ...
@@ -66,8 +66,8 @@ class MutableString(UserString, MutableSequence[MutableString]):
6666
def __getitem__(self: _MST, i: int) -> _MST: ...
6767
@overload
6868
def __getitem__(self: _MST, s: slice) -> _MST: ...
69-
def __setitem__(self, index: Union[int, slice], sub: Any) -> None: ...
70-
def __delitem__(self, index: Union[int, slice]) -> None: ...
69+
def __setitem__(self, index: int | slice, sub: Any) -> None: ...
70+
def __delitem__(self, index: int | slice) -> None: ...
7171
def immutable(self) -> UserString: ...
7272
def __iadd__(self: _MST, other: Any) -> _MST: ...
7373
def __imul__(self, n: int) -> _MST: ...

0 commit comments

Comments
 (0)