Skip to content

Commit 756277c

Browse files
authored
Sync typeshed (#12321)
Source commit: python/typeshed@3c85f36
1 parent 222029b commit 756277c

File tree

633 files changed

+13444
-6825
lines changed

Some content is hidden

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

633 files changed

+13444
-6825
lines changed

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

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

55
class HTTPServer(SocketServer.TCPServer):
66
server_name: str
77
server_port: int
8-
def __init__(self, server_address: Tuple[str, int], RequestHandlerClass: Callable[..., BaseHTTPRequestHandler]) -> None: ...
8+
def __init__(self, server_address: tuple[str, int], RequestHandlerClass: Callable[..., BaseHTTPRequestHandler]) -> None: ...
99

1010
class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
11-
client_address: Tuple[str, int]
11+
client_address: tuple[str, int]
1212
server: SocketServer.BaseServer
1313
close_connection: bool
1414
command: str
@@ -23,8 +23,8 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
2323
error_content_type: str
2424
protocol_version: str
2525
MessageClass: type
26-
responses: Mapping[int, Tuple[str, str]]
27-
def __init__(self, request: bytes, client_address: Tuple[str, int], server: SocketServer.BaseServer) -> None: ...
26+
responses: Mapping[int, tuple[str, str]]
27+
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: ...
3030
def send_error(self, code: int, message: str | None = ...) -> None: ...
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import SimpleHTTPServer
2-
from typing import List
32

43
class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
5-
cgi_directories: List[str]
4+
cgi_directories: list[str]
65
def do_POST(self) -> None: ...

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

Lines changed: 14 additions & 16 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, Sequence, Tuple
2+
from typing import IO, Any, Sequence
33

44
DEFAULTSECT: str
55
MAX_INTERPOLATION_DEPTH: int
@@ -9,8 +9,6 @@ class Error(Exception):
99
def __init__(self, msg: str = ...) -> None: ...
1010
def _get_message(self) -> None: ...
1111
def _set_message(self, value: str) -> None: ...
12-
def __repr__(self) -> str: ...
13-
def __str__(self) -> str: ...
1412

1513
class NoSectionError(Error):
1614
section: str
@@ -42,7 +40,7 @@ class InterpolationDepthError(InterpolationError):
4240

4341
class ParsingError(Error):
4442
filename: str
45-
errors: List[Tuple[Any, Any]]
43+
errors: list[tuple[Any, Any]]
4644
def __init__(self, filename: str) -> None: ...
4745
def append(self, lineno: Any, line: Any) -> None: ...
4846

@@ -53,26 +51,26 @@ class MissingSectionHeaderError(ParsingError):
5351

5452
class RawConfigParser:
5553
_dict: Any
56-
_sections: Dict[Any, Any]
57-
_defaults: Dict[Any, Any]
54+
_sections: dict[Any, Any]
55+
_defaults: dict[Any, Any]
5856
_optcre: Any
5957
SECTCRE: Any
6058
OPTCRE: Any
6159
OPTCRE_NV: Any
62-
def __init__(self, defaults: Dict[Any, Any] = ..., dict_type: Any = ..., allow_no_value: bool = ...) -> None: ...
63-
def defaults(self) -> Dict[Any, Any]: ...
64-
def sections(self) -> List[str]: ...
60+
def __init__(self, defaults: dict[Any, Any] = ..., dict_type: Any = ..., allow_no_value: bool = ...) -> None: ...
61+
def defaults(self) -> dict[Any, Any]: ...
62+
def sections(self) -> list[str]: ...
6563
def add_section(self, section: str) -> None: ...
6664
def has_section(self, section: str) -> bool: ...
67-
def options(self, section: str) -> List[str]: ...
68-
def read(self, filenames: str | Sequence[str]) -> List[str]: ...
65+
def options(self, section: str) -> list[str]: ...
66+
def read(self, filenames: str | Sequence[str]) -> list[str]: ...
6967
def readfp(self, fp: SupportsNoArgReadline[str], filename: str = ...) -> None: ...
7068
def get(self, section: str, option: str) -> str: ...
71-
def items(self, section: str) -> List[Tuple[Any, Any]]: ...
69+
def items(self, section: str) -> list[tuple[Any, Any]]: ...
7270
def _get(self, section: str, conv: type, option: str) -> Any: ...
7371
def getint(self, section: str, option: str) -> int: ...
7472
def getfloat(self, section: str, option: str) -> float: ...
75-
_boolean_states: Dict[str, bool]
73+
_boolean_states: dict[str, bool]
7674
def getboolean(self, section: str, option: str) -> bool: ...
7775
def optionxform(self, optionstr: str) -> str: ...
7876
def has_option(self, section: str, option: str) -> bool: ...
@@ -84,14 +82,14 @@ class RawConfigParser:
8482

8583
class ConfigParser(RawConfigParser):
8684
_KEYCRE: 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]]: ...
85+
def get(self, section: str, option: str, raw: bool = ..., vars: dict[Any, Any] | None = ...) -> Any: ...
86+
def items(self, section: str, raw: bool = ..., vars: dict[Any, Any] | None = ...) -> list[tuple[str, Any]]: ...
8987
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
9088
def _interpolation_replace(self, match: Any) -> str: ...
9189

9290
class SafeConfigParser(ConfigParser):
9391
_interpvar_re: Any
9492
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
9593
def _interpolate_some(
96-
self, option: str, accum: List[Any], rest: str, section: str, map: Dict[Any, Any], depth: int
94+
self, option: str, accum: list[Any], rest: str, section: str, map: dict[Any, Any], depth: int
9795
) -> None: ...

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

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

33
class CookieError(Exception): ...
44

5-
class Morsel(Dict[Any, Any]):
5+
class Morsel(dict[Any, Any]):
66
key: Any
77
def __init__(self): ...
88
def __setitem__(self, K, V): ...
@@ -14,7 +14,7 @@ class Morsel(Dict[Any, Any]):
1414
def js_output(self, attrs: Any | None = ...): ...
1515
def OutputString(self, attrs: Any | None = ...): ...
1616

17-
class BaseCookie(Dict[Any, Any]):
17+
class BaseCookie(dict[Any, Any]):
1818
def value_decode(self, val): ...
1919
def value_encode(self, val): ...
2020
def __init__(self, input: Any | None = ...): ...

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import AnyStr, List, Tuple
1+
from typing import AnyStr
22

33
from markupbase import ParserBase
44

@@ -10,8 +10,8 @@ class HTMLParser(ParserBase):
1010
def get_starttag_text(self) -> AnyStr: ...
1111
def set_cdata_mode(self, AnyStr) -> None: ...
1212
def clear_cdata_mode(self) -> None: ...
13-
def handle_startendtag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ...
14-
def handle_starttag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ...
13+
def handle_startendtag(self, tag: AnyStr, attrs: list[tuple[AnyStr, AnyStr]]): ...
14+
def handle_starttag(self, tag: AnyStr, attrs: list[tuple[AnyStr, AnyStr]]): ...
1515
def handle_endtag(self, tag: AnyStr): ...
1616
def handle_charref(self, name: AnyStr): ...
1717
def handle_entityref(self, name: AnyStr): ...

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Deque, Generic, TypeVar
1+
from collections import deque
2+
from typing import Any, Generic, TypeVar
23

34
_T = TypeVar("_T")
45

@@ -12,7 +13,7 @@ class Queue(Generic[_T]):
1213
not_full: Any
1314
all_tasks_done: Any
1415
unfinished_tasks: Any
15-
queue: Deque[Any] # undocumented
16+
queue: deque[Any] # undocumented
1617
def __init__(self, maxsize: int = ...) -> None: ...
1718
def task_done(self) -> None: ...
1819
def join(self) -> None: ...

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

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

55
class BaseServer:
66
address_family: int
77
RequestHandlerClass: Callable[..., BaseRequestHandler]
8-
server_address: Tuple[str, int]
8+
server_address: tuple[str, int]
99
socket: SocketType
1010
allow_reuse_address: bool
1111
request_queue_size: int
@@ -17,27 +17,27 @@ class BaseServer:
1717
def serve_forever(self, poll_interval: float = ...) -> None: ...
1818
def shutdown(self) -> None: ...
1919
def server_close(self) -> None: ...
20-
def finish_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
21-
def get_request(self) -> Tuple[SocketType, Tuple[str, int]]: ...
22-
def handle_error(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
20+
def finish_request(self, request: bytes, client_address: tuple[str, int]) -> None: ...
21+
def get_request(self) -> tuple[SocketType, tuple[str, int]]: ...
22+
def handle_error(self, request: bytes, client_address: tuple[str, int]) -> None: ...
2323
def handle_timeout(self) -> None: ...
24-
def process_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
24+
def process_request(self, request: bytes, client_address: tuple[str, int]) -> None: ...
2525
def server_activate(self) -> None: ...
2626
def server_bind(self) -> None: ...
27-
def verify_request(self, request: bytes, client_address: Tuple[str, int]) -> bool: ...
27+
def verify_request(self, request: bytes, client_address: tuple[str, int]) -> bool: ...
2828

2929
class TCPServer(BaseServer):
3030
def __init__(
3131
self,
32-
server_address: Tuple[str, int],
32+
server_address: tuple[str, int],
3333
RequestHandlerClass: Callable[..., BaseRequestHandler],
3434
bind_and_activate: bool = ...,
3535
) -> None: ...
3636

3737
class UDPServer(BaseServer):
3838
def __init__(
3939
self,
40-
server_address: Tuple[str, int],
40+
server_address: tuple[str, int],
4141
RequestHandlerClass: Callable[..., BaseRequestHandler],
4242
bind_and_activate: bool = ...,
4343
) -> None: ...
@@ -50,6 +50,7 @@ if sys.platform != "win32":
5050
RequestHandlerClass: Callable[..., BaseRequestHandler],
5151
bind_and_activate: bool = ...,
5252
) -> None: ...
53+
5354
class UnixDatagramServer(BaseServer):
5455
def __init__(
5556
self,
@@ -61,16 +62,16 @@ if sys.platform != "win32":
6162
if sys.platform != "win32":
6263
class ForkingMixIn:
6364
timeout: float | None # undocumented
64-
active_children: List[int] | None # undocumented
65+
active_children: list[int] | None # undocumented
6566
max_children: int # undocumented
6667
def collect_children(self) -> None: ... # undocumented
6768
def handle_timeout(self) -> None: ... # undocumented
68-
def process_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
69+
def process_request(self, request: bytes, client_address: tuple[str, int]) -> None: ...
6970

7071
class ThreadingMixIn:
7172
daemon_threads: bool
72-
def process_request_thread(self, request: bytes, client_address: Tuple[str, int]) -> None: ... # undocumented
73-
def process_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
73+
def process_request_thread(self, request: bytes, client_address: tuple[str, int]) -> None: ... # undocumented
74+
def process_request(self, request: bytes, client_address: tuple[str, int]) -> None: ...
7475

7576
if sys.platform != "win32":
7677
class ForkingTCPServer(ForkingMixIn, TCPServer): ...

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
1+
from typing import IO, Any, AnyStr, Generic, Iterable, Iterator
22

33
class StringIO(IO[AnyStr], Generic[AnyStr]):
44
closed: bool
@@ -14,7 +14,7 @@ class StringIO(IO[AnyStr], Generic[AnyStr]):
1414
def tell(self) -> int: ...
1515
def read(self, n: int = ...) -> AnyStr: ...
1616
def readline(self, length: int = ...) -> AnyStr: ...
17-
def readlines(self, sizehint: int = ...) -> List[AnyStr]: ...
17+
def readlines(self, sizehint: int = ...) -> list[AnyStr]: ...
1818
def truncate(self, size: int | None = ...) -> int: ...
1919
def write(self, s: AnyStr) -> int: ...
2020
def writelines(self, iterable: Iterable[AnyStr]) -> None: ...
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from typing import Any, Container, Dict, Generic, Iterable, Iterator, List, Mapping, Sized, Tuple, TypeVar, overload
1+
from typing import Any, Container, Generic, Iterable, Iterator, Mapping, Sized, TypeVar, overload
22

33
_KT = TypeVar("_KT")
44
_VT = TypeVar("_VT")
55
_T = TypeVar("_T")
66

7-
class UserDict(Dict[_KT, _VT], Generic[_KT, _VT]):
8-
data: Dict[_KT, _VT]
7+
class UserDict(dict[_KT, _VT], Generic[_KT, _VT]):
8+
data: dict[_KT, _VT]
99
def __init__(self, initialdata: Mapping[_KT, _VT] = ...) -> None: ...
1010
# TODO: __iter__ is not available for UserDict
1111

@@ -21,18 +21,18 @@ class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]):
2121
def get(self, k: _KT) -> _VT | None: ...
2222
@overload
2323
def get(self, k: _KT, default: _VT | _T) -> _VT | _T: ...
24-
def values(self) -> List[_VT]: ...
25-
def items(self) -> List[Tuple[_KT, _VT]]: ...
24+
def values(self) -> list[_VT]: ...
25+
def items(self) -> list[tuple[_KT, _VT]]: ...
2626
def iterkeys(self) -> Iterator[_KT]: ...
2727
def itervalues(self) -> Iterator[_VT]: ...
28-
def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ...
28+
def iteritems(self) -> Iterator[tuple[_KT, _VT]]: ...
2929
def __contains__(self, o: Any) -> bool: ...
3030
# From typing.MutableMapping[_KT, _VT]
3131
def clear(self) -> None: ...
3232
def pop(self, k: _KT, default: _VT = ...) -> _VT: ...
33-
def popitem(self) -> Tuple[_KT, _VT]: ...
33+
def popitem(self) -> tuple[_KT, _VT]: ...
3434
def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ...
3535
@overload
3636
def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
3737
@overload
38-
def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
38+
def update(self, m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from typing import Iterable, List, MutableSequence, TypeVar, overload
1+
from _typeshed import Self
2+
from typing import Iterable, MutableSequence, TypeVar, overload
23

34
_T = TypeVar("_T")
4-
_S = TypeVar("_S")
55

66
class UserList(MutableSequence[_T]):
7-
data: List[_T]
7+
data: list[_T]
88
def insert(self, index: int, object: _T) -> None: ...
99
@overload
1010
def __setitem__(self, i: int, o: _T) -> None: ...
@@ -15,5 +15,5 @@ class UserList(MutableSequence[_T]):
1515
@overload
1616
def __getitem__(self, i: int) -> _T: ...
1717
@overload
18-
def __getitem__(self: _S, s: slice) -> _S: ...
18+
def __getitem__(self: Self, s: slice) -> Self: ...
1919
def sort(self) -> None: ...

0 commit comments

Comments
 (0)