Skip to content

Commit 29c71ff

Browse files
authored
Add back tornado stubs for Python 2 only (#4412)
Tornado ships with inline annotations, but it no longer is Python 2 compatible. I think that it makes sense to keep the legacy stubs for Python 2 compatibility, at least for a while longer. This restores stubs removed in #4321, but moves them to `third_party/2`.
1 parent 4233008 commit 29c71ff

14 files changed

+1028
-0
lines changed

third_party/2/tornado/__init__.pyi

Whitespace-only changes.

third_party/2/tornado/concurrent.pyi

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from typing import Any
2+
3+
futures: Any
4+
5+
class ReturnValueIgnoredError(Exception): ...
6+
7+
class _TracebackLogger:
8+
exc_info: Any
9+
formatted_tb: Any
10+
def __init__(self, exc_info) -> None: ...
11+
def activate(self): ...
12+
def clear(self): ...
13+
def __del__(self): ...
14+
15+
class Future:
16+
def __init__(self) -> None: ...
17+
def cancel(self): ...
18+
def cancelled(self): ...
19+
def running(self): ...
20+
def done(self): ...
21+
def result(self, timeout=...): ...
22+
def exception(self, timeout=...): ...
23+
def add_done_callback(self, fn): ...
24+
def set_result(self, result): ...
25+
def set_exception(self, exception): ...
26+
def exc_info(self): ...
27+
def set_exc_info(self, exc_info): ...
28+
def __del__(self): ...
29+
30+
TracebackFuture: Any
31+
FUTURES: Any
32+
33+
def is_future(x): ...
34+
35+
class DummyExecutor:
36+
def submit(self, fn, *args, **kwargs): ...
37+
def shutdown(self, wait=...): ...
38+
39+
dummy_executor: Any
40+
41+
def run_on_executor(*args, **kwargs): ...
42+
def return_future(f): ...
43+
def chain_future(a, b): ...

third_party/2/tornado/gen.pyi

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
from typing import Any, Dict, NamedTuple, Tuple
2+
3+
singledispatch: Any
4+
5+
class KeyReuseError(Exception): ...
6+
class UnknownKeyError(Exception): ...
7+
class LeakedCallbackError(Exception): ...
8+
class BadYieldError(Exception): ...
9+
class ReturnValueIgnoredError(Exception): ...
10+
class TimeoutError(Exception): ...
11+
12+
def engine(func): ...
13+
def coroutine(func, replace_callback=...): ...
14+
15+
class Return(Exception):
16+
value: Any
17+
def __init__(self, value=...) -> None: ...
18+
19+
class WaitIterator:
20+
current_index: Any
21+
def __init__(self, *args, **kwargs) -> None: ...
22+
def done(self): ...
23+
def next(self): ...
24+
25+
class YieldPoint:
26+
def start(self, runner): ...
27+
def is_ready(self): ...
28+
def get_result(self): ...
29+
30+
class Callback(YieldPoint):
31+
key: Any
32+
def __init__(self, key) -> None: ...
33+
runner: Any
34+
def start(self, runner): ...
35+
def is_ready(self): ...
36+
def get_result(self): ...
37+
38+
class Wait(YieldPoint):
39+
key: Any
40+
def __init__(self, key) -> None: ...
41+
runner: Any
42+
def start(self, runner): ...
43+
def is_ready(self): ...
44+
def get_result(self): ...
45+
46+
class WaitAll(YieldPoint):
47+
keys: Any
48+
def __init__(self, keys) -> None: ...
49+
runner: Any
50+
def start(self, runner): ...
51+
def is_ready(self): ...
52+
def get_result(self): ...
53+
54+
def Task(func, *args, **kwargs): ...
55+
56+
class YieldFuture(YieldPoint):
57+
future: Any
58+
io_loop: Any
59+
def __init__(self, future, io_loop=...) -> None: ...
60+
runner: Any
61+
key: Any
62+
result_fn: Any
63+
def start(self, runner): ...
64+
def is_ready(self): ...
65+
def get_result(self): ...
66+
67+
class Multi(YieldPoint):
68+
keys: Any
69+
children: Any
70+
unfinished_children: Any
71+
quiet_exceptions: Any
72+
def __init__(self, children, quiet_exceptions=...) -> None: ...
73+
def start(self, runner): ...
74+
def is_ready(self): ...
75+
def get_result(self): ...
76+
77+
def multi_future(children, quiet_exceptions=...): ...
78+
def maybe_future(x): ...
79+
def with_timeout(timeout, future, io_loop=..., quiet_exceptions=...): ...
80+
def sleep(duration): ...
81+
82+
moment: Any
83+
84+
class Runner:
85+
gen: Any
86+
result_future: Any
87+
future: Any
88+
yield_point: Any
89+
pending_callbacks: Any
90+
results: Any
91+
running: Any
92+
finished: Any
93+
had_exception: Any
94+
io_loop: Any
95+
stack_context_deactivate: Any
96+
def __init__(self, gen, result_future, first_yielded) -> None: ...
97+
def register_callback(self, key): ...
98+
def is_ready(self, key): ...
99+
def set_result(self, key, result): ...
100+
def pop_result(self, key): ...
101+
def run(self): ...
102+
def handle_yield(self, yielded): ...
103+
def result_callback(self, key): ...
104+
def handle_exception(self, typ, value, tb): ...
105+
106+
class Arguments(NamedTuple):
107+
args: Tuple[str, ...]
108+
kwargs: Dict[str, Any]
109+
110+
def convert_yielded(yielded): ...

third_party/2/tornado/httpclient.pyi

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
from typing import Any
2+
3+
from tornado.util import Configurable
4+
5+
class HTTPClient:
6+
def __init__(self, async_client_class=..., **kwargs) -> None: ...
7+
def __del__(self): ...
8+
def close(self): ...
9+
def fetch(self, request, **kwargs): ...
10+
11+
class AsyncHTTPClient(Configurable):
12+
@classmethod
13+
def configurable_base(cls): ...
14+
@classmethod
15+
def configurable_default(cls): ...
16+
def __new__(cls, io_loop=..., force_instance=..., **kwargs): ...
17+
io_loop: Any
18+
defaults: Any
19+
def initialize(self, io_loop, defaults=...): ...
20+
def close(self): ...
21+
def fetch(self, request, callback=..., raise_error=..., **kwargs): ...
22+
def fetch_impl(self, request, callback): ...
23+
@classmethod
24+
def configure(cls, impl, **kwargs): ...
25+
26+
class HTTPRequest:
27+
proxy_host: Any
28+
proxy_port: Any
29+
proxy_username: Any
30+
proxy_password: Any
31+
url: Any
32+
method: Any
33+
body_producer: Any
34+
auth_username: Any
35+
auth_password: Any
36+
auth_mode: Any
37+
connect_timeout: Any
38+
request_timeout: Any
39+
follow_redirects: Any
40+
max_redirects: Any
41+
user_agent: Any
42+
decompress_response: Any
43+
network_interface: Any
44+
streaming_callback: Any
45+
header_callback: Any
46+
prepare_curl_callback: Any
47+
allow_nonstandard_methods: Any
48+
validate_cert: Any
49+
ca_certs: Any
50+
allow_ipv6: Any
51+
client_key: Any
52+
client_cert: Any
53+
ssl_options: Any
54+
expect_100_continue: Any
55+
start_time: Any
56+
def __init__(
57+
self,
58+
url,
59+
method=...,
60+
headers=...,
61+
body=...,
62+
auth_username=...,
63+
auth_password=...,
64+
auth_mode=...,
65+
connect_timeout=...,
66+
request_timeout=...,
67+
if_modified_since=...,
68+
follow_redirects=...,
69+
max_redirects=...,
70+
user_agent=...,
71+
use_gzip=...,
72+
network_interface=...,
73+
streaming_callback=...,
74+
header_callback=...,
75+
prepare_curl_callback=...,
76+
proxy_host=...,
77+
proxy_port=...,
78+
proxy_username=...,
79+
proxy_password=...,
80+
allow_nonstandard_methods=...,
81+
validate_cert=...,
82+
ca_certs=...,
83+
allow_ipv6=...,
84+
client_key=...,
85+
client_cert=...,
86+
body_producer=...,
87+
expect_100_continue=...,
88+
decompress_response=...,
89+
ssl_options=...,
90+
) -> None: ...
91+
@property
92+
def headers(self): ...
93+
@headers.setter
94+
def headers(self, value): ...
95+
@property
96+
def body(self): ...
97+
@body.setter
98+
def body(self, value): ...
99+
100+
class HTTPResponse:
101+
request: Any
102+
code: Any
103+
reason: Any
104+
headers: Any
105+
buffer: Any
106+
effective_url: Any
107+
error: Any
108+
request_time: Any
109+
time_info: Any
110+
def __init__(
111+
self, request, code, headers=..., buffer=..., effective_url=..., error=..., request_time=..., time_info=..., reason=...
112+
) -> None: ...
113+
body: bytes
114+
def rethrow(self): ...
115+
116+
class HTTPError(Exception):
117+
code: Any
118+
response: Any
119+
def __init__(self, code, message=..., response=...) -> None: ...
120+
121+
class _RequestProxy:
122+
request: Any
123+
defaults: Any
124+
def __init__(self, request, defaults) -> None: ...
125+
def __getattr__(self, name): ...
126+
127+
def main(): ...

third_party/2/tornado/httpserver.pyi

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from typing import Any
2+
3+
from tornado import httputil
4+
from tornado.tcpserver import TCPServer
5+
from tornado.util import Configurable
6+
7+
class HTTPServer(TCPServer, Configurable, httputil.HTTPServerConnectionDelegate):
8+
def __init__(self, *args, **kwargs) -> None: ...
9+
request_callback: Any
10+
no_keep_alive: Any
11+
xheaders: Any
12+
protocol: Any
13+
conn_params: Any
14+
def initialize(
15+
self,
16+
request_callback,
17+
no_keep_alive=...,
18+
io_loop=...,
19+
xheaders=...,
20+
ssl_options=...,
21+
protocol=...,
22+
decompress_request=...,
23+
chunk_size=...,
24+
max_header_size=...,
25+
idle_connection_timeout=...,
26+
body_timeout=...,
27+
max_body_size=...,
28+
max_buffer_size=...,
29+
): ...
30+
@classmethod
31+
def configurable_base(cls): ...
32+
@classmethod
33+
def configurable_default(cls): ...
34+
def close_all_connections(self): ...
35+
def handle_stream(self, stream, address): ...
36+
def start_request(self, server_conn, request_conn): ...
37+
def on_close(self, server_conn): ...
38+
39+
class _HTTPRequestContext:
40+
address: Any
41+
protocol: Any
42+
address_family: Any
43+
remote_ip: Any
44+
def __init__(self, stream, address, protocol) -> None: ...
45+
46+
class _ServerRequestAdapter(httputil.HTTPMessageDelegate):
47+
server: Any
48+
connection: Any
49+
request: Any
50+
delegate: Any
51+
def __init__(self, server, server_conn, request_conn) -> None: ...
52+
def headers_received(self, start_line, headers): ...
53+
def data_received(self, chunk): ...
54+
def finish(self): ...
55+
def on_connection_close(self): ...
56+
57+
HTTPRequest: Any

0 commit comments

Comments
 (0)