Skip to content

Commit

Permalink
Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where poss…
Browse files Browse the repository at this point in the history
…ible (#6949)
  • Loading branch information
AlexWaygood committed Jan 18, 2022
1 parent aa885ec commit 8af5e0d
Show file tree
Hide file tree
Showing 264 changed files with 2,217 additions and 2,411 deletions.
10 changes: 5 additions & 5 deletions stdlib/@python2/BaseHTTPServer.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import mimetools
import SocketServer
from typing import Any, BinaryIO, Callable, Mapping, Tuple
from typing import Any, BinaryIO, Callable, Mapping

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

class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
client_address: Tuple[str, int]
client_address: tuple[str, int]
server: SocketServer.BaseServer
close_connection: bool
command: str
Expand All @@ -23,8 +23,8 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
error_content_type: str
protocol_version: str
MessageClass: type
responses: Mapping[int, Tuple[str, str]]
def __init__(self, request: bytes, client_address: Tuple[str, int], server: SocketServer.BaseServer) -> None: ...
responses: Mapping[int, tuple[str, str]]
def __init__(self, request: bytes, client_address: tuple[str, int], server: SocketServer.BaseServer) -> None: ...
def handle(self) -> None: ...
def handle_one_request(self) -> None: ...
def send_error(self, code: int, message: str | None = ...) -> None: ...
Expand Down
3 changes: 1 addition & 2 deletions stdlib/@python2/CGIHTTPServer.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import SimpleHTTPServer
from typing import List

class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
cgi_directories: List[str]
cgi_directories: list[str]
def do_POST(self) -> None: ...
28 changes: 14 additions & 14 deletions stdlib/@python2/ConfigParser.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import SupportsNoArgReadline
from typing import IO, Any, Dict, List, Sequence, Tuple
from typing import IO, Any, Sequence

DEFAULTSECT: str
MAX_INTERPOLATION_DEPTH: int
Expand Down Expand Up @@ -42,7 +42,7 @@ class InterpolationDepthError(InterpolationError):

class ParsingError(Error):
filename: str
errors: List[Tuple[Any, Any]]
errors: list[tuple[Any, Any]]
def __init__(self, filename: str) -> None: ...
def append(self, lineno: Any, line: Any) -> None: ...

Expand All @@ -53,26 +53,26 @@ class MissingSectionHeaderError(ParsingError):

class RawConfigParser:
_dict: Any
_sections: Dict[Any, Any]
_defaults: Dict[Any, Any]
_sections: dict[Any, Any]
_defaults: dict[Any, Any]
_optcre: Any
SECTCRE: Any
OPTCRE: Any
OPTCRE_NV: Any
def __init__(self, defaults: Dict[Any, Any] = ..., dict_type: Any = ..., allow_no_value: bool = ...) -> None: ...
def defaults(self) -> Dict[Any, Any]: ...
def sections(self) -> List[str]: ...
def __init__(self, defaults: dict[Any, Any] = ..., dict_type: Any = ..., allow_no_value: bool = ...) -> None: ...
def defaults(self) -> dict[Any, Any]: ...
def sections(self) -> list[str]: ...
def add_section(self, section: str) -> None: ...
def has_section(self, section: str) -> bool: ...
def options(self, section: str) -> List[str]: ...
def read(self, filenames: str | Sequence[str]) -> List[str]: ...
def options(self, section: str) -> list[str]: ...
def read(self, filenames: str | Sequence[str]) -> list[str]: ...
def readfp(self, fp: SupportsNoArgReadline[str], filename: str = ...) -> None: ...
def get(self, section: str, option: str) -> str: ...
def items(self, section: str) -> List[Tuple[Any, Any]]: ...
def items(self, section: str) -> list[tuple[Any, Any]]: ...
def _get(self, section: str, conv: type, option: str) -> Any: ...
def getint(self, section: str, option: str) -> int: ...
def getfloat(self, section: str, option: str) -> float: ...
_boolean_states: Dict[str, bool]
_boolean_states: dict[str, bool]
def getboolean(self, section: str, option: str) -> bool: ...
def optionxform(self, optionstr: str) -> str: ...
def has_option(self, section: str, option: str) -> bool: ...
Expand All @@ -84,14 +84,14 @@ class RawConfigParser:

class ConfigParser(RawConfigParser):
_KEYCRE: Any
def get(self, section: str, option: str, raw: bool = ..., vars: Dict[Any, Any] | None = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: Dict[Any, Any] | None = ...) -> List[Tuple[str, Any]]: ...
def get(self, section: str, option: str, raw: bool = ..., vars: dict[Any, Any] | None = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: dict[Any, Any] | None = ...) -> list[tuple[str, Any]]: ...
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolation_replace(self, match: Any) -> str: ...

class SafeConfigParser(ConfigParser):
_interpvar_re: Any
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolate_some(
self, option: str, accum: List[Any], rest: str, section: str, map: Dict[Any, Any], depth: int
self, option: str, accum: list[Any], rest: str, section: str, map: dict[Any, Any], depth: int
) -> None: ...
6 changes: 3 additions & 3 deletions stdlib/@python2/Cookie.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Any, Dict
from typing import Any

class CookieError(Exception): ...

class Morsel(Dict[Any, Any]):
class Morsel(dict[Any, Any]):
key: Any
def __init__(self): ...
def __setitem__(self, K, V): ...
Expand All @@ -14,7 +14,7 @@ class Morsel(Dict[Any, Any]):
def js_output(self, attrs: Any | None = ...): ...
def OutputString(self, attrs: Any | None = ...): ...

class BaseCookie(Dict[Any, Any]):
class BaseCookie(dict[Any, Any]):
def value_decode(self, val): ...
def value_encode(self, val): ...
def __init__(self, input: Any | None = ...): ...
Expand Down
6 changes: 3 additions & 3 deletions stdlib/@python2/HTMLParser.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import AnyStr, List, Tuple
from typing import AnyStr

from markupbase import ParserBase

Expand All @@ -10,8 +10,8 @@ class HTMLParser(ParserBase):
def get_starttag_text(self) -> AnyStr: ...
def set_cdata_mode(self, AnyStr) -> None: ...
def clear_cdata_mode(self) -> None: ...
def handle_startendtag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ...
def handle_starttag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ...
def handle_startendtag(self, tag: AnyStr, attrs: list[tuple[AnyStr, AnyStr]]): ...
def handle_starttag(self, tag: AnyStr, attrs: list[tuple[AnyStr, AnyStr]]): ...
def handle_endtag(self, tag: AnyStr): ...
def handle_charref(self, name: AnyStr): ...
def handle_entityref(self, name: AnyStr): ...
Expand Down
5 changes: 3 additions & 2 deletions stdlib/@python2/Queue.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Deque, Generic, TypeVar
from collections import deque
from typing import Any, Generic, TypeVar

_T = TypeVar("_T")

Expand All @@ -12,7 +13,7 @@ class Queue(Generic[_T]):
not_full: Any
all_tasks_done: Any
unfinished_tasks: Any
queue: Deque[Any] # undocumented
queue: deque[Any] # undocumented
def __init__(self, maxsize: int = ...) -> None: ...
def task_done(self) -> None: ...
def join(self) -> None: ...
Expand Down
26 changes: 13 additions & 13 deletions stdlib/@python2/SocketServer.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import sys
from socket import SocketType
from typing import Any, BinaryIO, Callable, ClassVar, List, Text, Tuple, Union
from typing import Any, BinaryIO, Callable, ClassVar, Text, Union

class BaseServer:
address_family: int
RequestHandlerClass: Callable[..., BaseRequestHandler]
server_address: Tuple[str, int]
server_address: tuple[str, int]
socket: SocketType
allow_reuse_address: bool
request_queue_size: int
Expand All @@ -17,27 +17,27 @@ class BaseServer:
def serve_forever(self, poll_interval: float = ...) -> None: ...
def shutdown(self) -> None: ...
def server_close(self) -> None: ...
def finish_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
def get_request(self) -> Tuple[SocketType, Tuple[str, int]]: ...
def handle_error(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
def finish_request(self, request: bytes, client_address: tuple[str, int]) -> None: ...
def get_request(self) -> tuple[SocketType, tuple[str, int]]: ...
def handle_error(self, request: bytes, client_address: tuple[str, int]) -> None: ...
def handle_timeout(self) -> None: ...
def process_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
def process_request(self, request: bytes, client_address: tuple[str, int]) -> None: ...
def server_activate(self) -> None: ...
def server_bind(self) -> None: ...
def verify_request(self, request: bytes, client_address: Tuple[str, int]) -> bool: ...
def verify_request(self, request: bytes, client_address: tuple[str, int]) -> bool: ...

class TCPServer(BaseServer):
def __init__(
self,
server_address: Tuple[str, int],
server_address: tuple[str, int],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...,
) -> None: ...

class UDPServer(BaseServer):
def __init__(
self,
server_address: Tuple[str, int],
server_address: tuple[str, int],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...,
) -> None: ...
Expand All @@ -61,16 +61,16 @@ if sys.platform != "win32":
if sys.platform != "win32":
class ForkingMixIn:
timeout: float | None # undocumented
active_children: List[int] | None # undocumented
active_children: list[int] | None # undocumented
max_children: int # undocumented
def collect_children(self) -> None: ... # undocumented
def handle_timeout(self) -> None: ... # undocumented
def process_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
def process_request(self, request: bytes, client_address: tuple[str, int]) -> None: ...

class ThreadingMixIn:
daemon_threads: bool
def process_request_thread(self, request: bytes, client_address: Tuple[str, int]) -> None: ... # undocumented
def process_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
def process_request_thread(self, request: bytes, client_address: tuple[str, int]) -> None: ... # undocumented
def process_request(self, request: bytes, client_address: tuple[str, int]) -> None: ...

if sys.platform != "win32":
class ForkingTCPServer(ForkingMixIn, TCPServer): ...
Expand Down
4 changes: 2 additions & 2 deletions stdlib/@python2/StringIO.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List
from typing import IO, Any, AnyStr, Generic, Iterable, Iterator

class StringIO(IO[AnyStr], Generic[AnyStr]):
closed: bool
Expand All @@ -14,7 +14,7 @@ class StringIO(IO[AnyStr], Generic[AnyStr]):
def tell(self) -> int: ...
def read(self, n: int = ...) -> AnyStr: ...
def readline(self, length: int = ...) -> AnyStr: ...
def readlines(self, sizehint: int = ...) -> List[AnyStr]: ...
def readlines(self, sizehint: int = ...) -> list[AnyStr]: ...
def truncate(self, size: int | None = ...) -> int: ...
def write(self, s: AnyStr) -> int: ...
def writelines(self, iterable: Iterable[AnyStr]) -> None: ...
Expand Down
16 changes: 8 additions & 8 deletions stdlib/@python2/UserDict.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Any, Container, Dict, Generic, Iterable, Iterator, List, Mapping, Sized, Tuple, TypeVar, overload
from typing import Any, Container, Generic, Iterable, Iterator, Mapping, Sized, TypeVar, overload

_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
_T = TypeVar("_T")

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

Expand All @@ -21,18 +21,18 @@ class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]):
def get(self, k: _KT) -> _VT | None: ...
@overload
def get(self, k: _KT, default: _VT | _T) -> _VT | _T: ...
def values(self) -> List[_VT]: ...
def items(self) -> List[Tuple[_KT, _VT]]: ...
def values(self) -> list[_VT]: ...
def items(self) -> list[tuple[_KT, _VT]]: ...
def iterkeys(self) -> Iterator[_KT]: ...
def itervalues(self) -> Iterator[_VT]: ...
def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ...
def iteritems(self) -> Iterator[tuple[_KT, _VT]]: ...
def __contains__(self, o: Any) -> bool: ...
# From typing.MutableMapping[_KT, _VT]
def clear(self) -> None: ...
def pop(self, k: _KT, default: _VT = ...) -> _VT: ...
def popitem(self) -> Tuple[_KT, _VT]: ...
def popitem(self) -> tuple[_KT, _VT]: ...
def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ...
@overload
def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
@overload
def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def update(self, m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
4 changes: 2 additions & 2 deletions stdlib/@python2/UserList.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from _typeshed import Self
from typing import Iterable, List, MutableSequence, TypeVar, overload
from typing import Iterable, MutableSequence, TypeVar, overload

_T = TypeVar("_T")

class UserList(MutableSequence[_T]):
data: List[_T]
data: list[_T]
def insert(self, index: int, object: _T) -> None: ...
@overload
def __setitem__(self, i: int, o: _T) -> None: ...
Expand Down
16 changes: 8 additions & 8 deletions stdlib/@python2/UserString.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Self
from typing import Any, Iterable, List, MutableSequence, Sequence, Text, Tuple, TypeVar, overload
from typing import Any, Iterable, MutableSequence, Sequence, Text, TypeVar, overload

_MST = TypeVar("_MST", bound=MutableString)

Expand All @@ -26,7 +26,7 @@ class UserString(Sequence[UserString]):
def count(self, sub: int, start: int = ..., end: int = ...) -> int: ...
def decode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ...
def encode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ...
def endswith(self, suffix: Text | Tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
def endswith(self, suffix: Text | tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
def expandtabs(self: Self, tabsize: int = ...) -> Self: ...
def find(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
def index(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
Expand All @@ -43,17 +43,17 @@ class UserString(Sequence[UserString]):
def ljust(self: Self, width: int, *args: Any) -> Self: ...
def lower(self: Self) -> Self: ...
def lstrip(self: Self, chars: Text | None = ...) -> Self: ...
def partition(self, sep: Text) -> Tuple[Text, Text, Text]: ...
def partition(self, sep: Text) -> tuple[Text, Text, Text]: ...
def replace(self: Self, old: Text, new: Text, maxsplit: int = ...) -> Self: ...
def rfind(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
def rindex(self, sub: Text, start: int = ..., end: int = ...) -> int: ...
def rjust(self: Self, width: int, *args: Any) -> Self: ...
def rpartition(self, sep: Text) -> Tuple[Text, Text, Text]: ...
def rpartition(self, sep: Text) -> tuple[Text, Text, Text]: ...
def rstrip(self: Self, chars: Text | None = ...) -> Self: ...
def split(self, sep: Text | None = ..., maxsplit: int = ...) -> List[Text]: ...
def rsplit(self, sep: Text | None = ..., maxsplit: int = ...) -> List[Text]: ...
def splitlines(self, keepends: int = ...) -> List[Text]: ...
def startswith(self, prefix: Text | Tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
def split(self, sep: Text | None = ..., maxsplit: int = ...) -> list[Text]: ...
def rsplit(self, sep: Text | None = ..., maxsplit: int = ...) -> list[Text]: ...
def splitlines(self, keepends: int = ...) -> list[Text]: ...
def startswith(self, prefix: Text | tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
def strip(self: Self, chars: Text | None = ...) -> Self: ...
def swapcase(self: Self) -> Self: ...
def title(self: Self) -> Self: ...
Expand Down
Loading

0 comments on commit 8af5e0d

Please sign in to comment.