Skip to content

Commit c8df617

Browse files
authored
Use built-in generic (#5050)
1 parent ffcd592 commit c8df617

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

stdlib/cgi.pyi

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from _typeshed import SupportsGetItem, SupportsItemAccess
33
from builtins import type as _type
4-
from typing import IO, Any, AnyStr, Dict, Iterable, Iterator, List, Mapping, Optional, Protocol, Tuple, TypeVar, Union
4+
from typing import IO, Any, AnyStr, Iterable, Iterator, Mapping, Optional, Protocol, TypeVar, Union
55

66
_T = TypeVar("_T", bound=FieldStorage)
77

@@ -10,28 +10,28 @@ def parse(
1010
environ: SupportsItemAccess[str, str] = ...,
1111
keep_blank_values: bool = ...,
1212
strict_parsing: bool = ...,
13-
) -> Dict[str, List[str]]: ...
13+
) -> dict[str, list[str]]: ...
1414

1515
if sys.version_info < (3, 8):
16-
def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
17-
def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> List[Tuple[str, str]]: ...
16+
def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> dict[str, list[str]]: ...
17+
def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> list[tuple[str, str]]: ...
1818

1919
if sys.version_info >= (3, 7):
2020
def parse_multipart(
2121
fp: IO[Any], pdict: SupportsGetItem[str, bytes], encoding: str = ..., errors: str = ...
22-
) -> Dict[str, List[Any]]: ...
22+
) -> dict[str, list[Any]]: ...
2323

2424
else:
25-
def parse_multipart(fp: IO[Any], pdict: SupportsGetItem[str, bytes]) -> Dict[str, List[bytes]]: ...
25+
def parse_multipart(fp: IO[Any], pdict: SupportsGetItem[str, bytes]) -> dict[str, list[bytes]]: ...
2626

2727
class _Environ(Protocol):
2828
def __getitem__(self, __k: str) -> str: ...
2929
def keys(self) -> Iterable[str]: ...
3030

31-
def parse_header(line: str) -> Tuple[str, Dict[str, str]]: ...
31+
def parse_header(line: str) -> tuple[str, dict[str, str]]: ...
3232
def test(environ: _Environ = ...) -> None: ...
3333
def print_environ(environ: _Environ = ...) -> None: ...
34-
def print_form(form: Dict[str, Any]) -> None: ...
34+
def print_form(form: dict[str, Any]) -> None: ...
3535
def print_directory() -> None: ...
3636
def print_environ_usage() -> None: ...
3737

@@ -47,15 +47,17 @@ class MiniFieldStorage:
4747
list: Any
4848
type: Any
4949
file: Optional[IO[bytes]]
50-
type_options: Dict[Any, Any]
50+
type_options: dict[Any, Any]
5151
disposition: Any
52-
disposition_options: Dict[Any, Any]
53-
headers: Dict[Any, Any]
52+
disposition_options: dict[Any, Any]
53+
headers: dict[Any, Any]
5454
name: Any
5555
value: Any
5656
def __init__(self, name: Any, value: Any) -> None: ...
5757
def __repr__(self) -> str: ...
5858

59+
_list = list
60+
5961
class FieldStorage(object):
6062
FieldStorageClass: Optional[_type]
6163
keep_blank_values: int
@@ -69,16 +71,16 @@ class FieldStorage(object):
6971
bytes_read: int
7072
limit: Optional[int]
7173
disposition: str
72-
disposition_options: Dict[str, str]
74+
disposition_options: dict[str, str]
7375
filename: Optional[str]
7476
file: Optional[IO[bytes]]
7577
type: str
76-
type_options: Dict[str, str]
78+
type_options: dict[str, str]
7779
innerboundary: bytes
7880
length: int
7981
done: int
80-
list: Optional[List[Any]]
81-
value: Union[None, bytes, List[Any]]
82+
list: Optional[_list[Any]]
83+
value: Union[None, bytes, _list[Any]]
8284

8385
if sys.version_info >= (3, 6):
8486
def __init__(
@@ -125,8 +127,8 @@ class FieldStorage(object):
125127
def __getitem__(self, key: str) -> Any: ...
126128
def getvalue(self, key: str, default: Any = ...) -> Any: ...
127129
def getfirst(self, key: str, default: Any = ...) -> Any: ...
128-
def getlist(self, key: str) -> List[Any]: ...
129-
def keys(self) -> List[str]: ...
130+
def getlist(self, key: str) -> _list[Any]: ...
131+
def keys(self) -> _list[str]: ...
130132
if sys.version_info < (3, 0):
131133
def has_key(self, key: str) -> bool: ...
132134
def __contains__(self, key: str) -> bool: ...
@@ -144,7 +146,7 @@ class FieldStorage(object):
144146

145147
if sys.version_info < (3, 0):
146148
from UserDict import UserDict
147-
class FormContentDict(UserDict[str, List[str]]):
149+
class FormContentDict(UserDict[str, list[str]]):
148150
query_string: str
149151
def __init__(self, environ: Mapping[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ...) -> None: ...
150152
class SvFormContentDict(FormContentDict):
@@ -159,4 +161,4 @@ if sys.version_info < (3, 0):
159161
def value(self, key: Any) -> Any: ...
160162
def length(self, key: Any) -> int: ...
161163
def stripped(self, key: Any) -> Any: ...
162-
def pars(self) -> Dict[Any, Any]: ...
164+
def pars(self) -> dict[Any, Any]: ...

stdlib/getopt.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from typing import List, Tuple
2-
3-
def getopt(args: List[str], shortopts: str, longopts: List[str] = ...) -> Tuple[List[Tuple[str, str]], List[str]]: ...
4-
def gnu_getopt(args: List[str], shortopts: str, longopts: List[str] = ...) -> Tuple[List[Tuple[str, str]], List[str]]: ...
1+
def getopt(args: list[str], shortopts: str, longopts: list[str] = ...) -> tuple[list[tuple[str, str]], list[str]]: ...
2+
def gnu_getopt(args: list[str], shortopts: str, longopts: list[str] = ...) -> tuple[list[tuple[str, str]], list[str]]: ...
53

64
class GetoptError(Exception):
75
msg: str

0 commit comments

Comments
 (0)