Skip to content

Commit

Permalink
Reformatted all files with black and isort
Browse files Browse the repository at this point in the history
A few comments between imports were removed or moved to the top of the
import block, due to behavioral differences between black and isort. See
psf/black#251 for details.

In two instances @Overloads at the top of the file needed to be moved
due to psf/black#1490.
  • Loading branch information
srittau committed Jun 11, 2020
1 parent 8100c0b commit 8154efd
Show file tree
Hide file tree
Showing 796 changed files with 13,705 additions and 10,258 deletions.
16 changes: 6 additions & 10 deletions stdlib/2/BaseHTTPServer.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Stubs for BaseHTTPServer (Python 2.7)

from typing import Any, BinaryIO, Callable, Mapping, Optional, Tuple, Union
import SocketServer
import mimetools
import SocketServer
from typing import Any, BinaryIO, Callable, Mapping, Optional, Tuple, Union

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]
Expand All @@ -27,18 +26,15 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
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: ...
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: Optional[str] = ...) -> None: ...
def send_response(self, code: int,
message: Optional[str] = ...) -> None: ...
def send_response(self, code: int, message: Optional[str] = ...) -> None: ...
def send_header(self, keyword: str, value: str) -> None: ...
def end_headers(self) -> None: ...
def flush_headers(self) -> None: ...
def log_request(self, code: Union[int, str] = ...,
size: Union[int, str] = ...) -> None: ...
def log_request(self, code: Union[int, str] = ..., size: Union[int, str] = ...) -> None: ...
def log_error(self, format: str, *args: Any) -> None: ...
def log_message(self, format: str, *args: Any) -> None: ...
def version_string(self) -> str: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/2/CGIHTTPServer.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Stubs for CGIHTTPServer (Python 2.7)

from typing import List
import SimpleHTTPServer
from typing import List

class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
cgi_directories: List[str]
Expand Down
2 changes: 1 addition & 1 deletion stdlib/2/ConfigParser.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, IO, Sequence, Tuple, Union, List, Dict, Protocol, Optional
from typing import IO, Any, Dict, List, Optional, Protocol, Sequence, Tuple, Union

DEFAULTSECT: str
MAX_INTERPOLATION_DEPTH: int
Expand Down
7 changes: 2 additions & 5 deletions stdlib/2/HTMLParser.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from typing import List, Tuple, AnyStr
from typing import AnyStr, List, Tuple

from markupbase import ParserBase

class HTMLParser(ParserBase):
def __init__(self) -> None: ...
def feed(self, feed: AnyStr) -> None: ...
def close(self) -> None: ...
def reset(self) -> None: ...

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_endtag(self, tag: AnyStr): ...
Expand All @@ -20,9 +19,7 @@ class HTMLParser(ParserBase):
def handle_comment(self, data: AnyStr): ...
def handle_decl(self, decl: AnyStr): ...
def handle_pi(self, data: AnyStr): ...

def unknown_decl(self, data: AnyStr): ...

def unescape(self, s: AnyStr) -> AnyStr: ...

class HTMLParseError(Exception):
Expand Down
4 changes: 2 additions & 2 deletions stdlib/2/Queue.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Stubs for Queue (Python 2)

from collections import deque
from typing import Any, Deque, TypeVar, Generic, Optional
from typing import Any, Deque, Generic, Optional, TypeVar

_T = TypeVar('_T')
_T = TypeVar("_T")

class Empty(Exception): ...
class Full(Exception): ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/2/SimpleHTTPServer.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Stubs for SimpleHTTPServer (Python 2)

from typing import Any, AnyStr, IO, Mapping, Optional, Union
import BaseHTTPServer
from StringIO import StringIO
from typing import IO, Any, AnyStr, Mapping, Optional, Union

class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
server_version: str
Expand Down
79 changes: 41 additions & 38 deletions stdlib/2/SocketServer.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# NB: SocketServer.pyi and socketserver.pyi must remain consistent!
# Stubs for socketserver

from typing import Any, BinaryIO, Callable, ClassVar, List, Optional, Tuple, Type, Text, Union
from socket import SocketType
import sys
import types
from socket import SocketType
from typing import Any, BinaryIO, Callable, ClassVar, List, Optional, Text, Tuple, Type, Union

class BaseServer:
address_family: int
Expand All @@ -15,53 +15,59 @@ class BaseServer:
request_queue_size: int
socket_type: int
timeout: Optional[float]
def __init__(self, server_address: Any,
RequestHandlerClass: Callable[..., BaseRequestHandler]) -> None: ...
def __init__(self, server_address: Any, RequestHandlerClass: Callable[..., BaseRequestHandler]) -> None: ...
def fileno(self) -> int: ...
def handle_request(self) -> None: ...
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 finish_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
def get_request(self) -> None: ...
def handle_error(self, request: bytes,
client_address: Tuple[str, int]) -> None: ...
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: ...
if sys.version_info >= (3, 6):
def __enter__(self) -> BaseServer: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[types.TracebackType]) -> None: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[types.TracebackType]
) -> None: ...
if sys.version_info >= (3, 3):
def service_actions(self) -> None: ...

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

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

if sys.platform != 'win32':
if sys.platform != "win32":
class UnixStreamServer(BaseServer):
def __init__(self, server_address: Union[Text, bytes],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...) -> None: ...

def __init__(
self,
server_address: Union[Text, bytes],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...,
) -> None: ...
class UnixDatagramServer(BaseServer):
def __init__(self, server_address: Union[Text, bytes],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...) -> None: ...
def __init__(
self,
server_address: Union[Text, bytes],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...,
) -> None: ...

if sys.platform != "win32":
class ForkingMixIn:
Expand All @@ -77,32 +83,30 @@ if sys.platform != "win32":
def handle_timeout(self) -> None: ... # undocumented
if sys.version_info >= (3, 3):
def service_actions(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: ...
if sys.version_info >= (3, 6):
def server_close(self) -> None: ...

class ThreadingMixIn:
daemon_threads: bool
if sys.version_info >= (3, 7):
block_on_close: 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.version_info >= (3, 6):
def server_close(self) -> None: ...

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

class ThreadingTCPServer(ThreadingMixIn, TCPServer): ...
class ThreadingUDPServer(ThreadingMixIn, UDPServer): ...
if sys.platform != 'win32':

if sys.platform != "win32":
class ThreadingUnixStreamServer(ThreadingMixIn, UnixStreamServer): ...
class ThreadingUnixDatagramServer(ThreadingMixIn, UnixDatagramServer): ...


class BaseRequestHandler:
# Those are technically of types, respectively:
# * Union[SocketType, Tuple[bytes, SocketType]]
Expand All @@ -113,7 +117,6 @@ class BaseRequestHandler:
request: Any
client_address: Any
server: BaseServer

def __init__(self, request: Any, client_address: Any, server: BaseServer) -> None: ...
def setup(self) -> None: ...
def handle(self) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/2/StringIO.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Stubs for StringIO (Python 2)

from typing import Any, IO, AnyStr, Iterator, Iterable, Generic, List, Optional
from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Optional

class StringIO(IO[AnyStr], Generic[AnyStr]):
closed: bool
Expand Down
33 changes: 21 additions & 12 deletions stdlib/2/UserDict.pyi
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
from typing import (Any, Container, Dict, Generic, Iterable, Iterator, List,
Mapping, Optional, Sized, Tuple, TypeVar, Union, overload)

_KT = TypeVar('_KT')
_VT = TypeVar('_VT')
_T = TypeVar('_T')
from typing import (
Any,
Container,
Dict,
Generic,
Iterable,
Iterator,
List,
Mapping,
Optional,
Sized,
Tuple,
TypeVar,
Union,
overload,
)

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

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

class IterableUserDict(UserDict[_KT, _VT], Generic[_KT, _VT]):
...
class IterableUserDict(UserDict[_KT, _VT], Generic[_KT, _VT]): ...

class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]):
def has_key(self, key: _KT) -> bool: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_KT]: ...

# From typing.Mapping[_KT, _VT]
# (can't inherit because of keys())
@overload
Expand All @@ -32,7 +42,6 @@ class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]):
def itervalues(self) -> Iterator[_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: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/2/UserList.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable, MutableSequence, TypeVar, Union, overload, List
from typing import Iterable, List, MutableSequence, TypeVar, Union, overload

_T = TypeVar("_T")
_S = TypeVar("_S")
Expand Down
2 changes: 1 addition & 1 deletion stdlib/2/UserString.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import collections
from typing import Any, Iterable, List, MutableSequence, Sequence, Optional, overload, Text, TypeVar, Tuple, Union
from typing import Any, Iterable, List, MutableSequence, Optional, Sequence, Text, Tuple, TypeVar, Union, overload

_UST = TypeVar("_UST", bound=UserString)
_MST = TypeVar("_MST", bound=MutableString)
Expand Down
Loading

0 comments on commit 8154efd

Please sign in to comment.