Skip to content

Commit fb01ccb

Browse files
committed
Fixes after Ivan's review.
1 parent aa52197 commit fb01ccb

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

third_party/2and3/flask/app.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@ class Flask(_PackageBoundObject):
6464
subdomain_matching: Any = ...
6565
cli: Any = ...
6666
def __init__(self, import_name: str, static_url_path: Optional[str] = ..., static_folder: str = ..., static_host: Optional[str] = ..., host_matching: bool = ..., subdomain_matching: bool = ..., template_folder: str = ..., instance_path: Optional[str] = ..., instance_relative_config: bool = ..., root_path: Optional[str] = ...) -> None: ...
67+
@property
6768
def name(self) -> str: ...
6869
@property
6970
def propagate_exceptions(self): ...
7071
@property
7172
def preserve_context_on_exception(self): ...
73+
@property
7274
def logger(self): ...
75+
@property
7376
def jinja_env(self): ...
7477
@property
7578
def got_first_request(self): ...
@@ -137,3 +140,8 @@ class Flask(_PackageBoundObject):
137140
def test_request_context(self, *args: Any, **kwargs: Any) -> ContextManager[RequestContext]: ...
138141
def wsgi_app(self, environ: Any, start_response: Any): ...
139142
def __call__(self, environ: Any, start_response: Any): ...
143+
144+
# These are not preset at runtime but we add them since monkeypatching this
145+
# class is quite common.
146+
def __setattr__(self, name: str, value: Any): ...
147+
def __getattr__(self, name: str): ...

third_party/2and3/flask/globals.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ from .wrappers import Request
77
from typing import Any
88
from werkzeug.local import LocalStack
99

10+
class _FlaskLocalProxy(Flask):
11+
def _get_current_object(self) -> Flask: ...
12+
1013
_request_ctx_stack: LocalStack
1114
_app_ctx_stack: LocalStack
12-
current_app: Flask
15+
current_app: _FlaskLocalProxy
1316
request: Request
1417
session: Any
1518
g: Any

third_party/2and3/flask/views.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ class View:
1818
class MethodViewType(type):
1919
def __init__(cls, name: Any, bases: Any, d: Any) -> None: ...
2020

21-
class MethodView:
21+
class MethodView(View, metaclass=MethodViewType):
2222
def dispatch_request(self, *args: Any, **kwargs: Any): ...

third_party/2and3/werkzeug/wrappers.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class BaseRequest:
6060
host = ... # type: Text
6161
query_string = ... # type: bytes
6262
method = ... # type: Text
63-
def access_route(self): ...
63+
@property
64+
def access_route(self) -> Sequence[str]: ...
6465
@property
6566
def remote_addr(self) -> str: ...
6667
remote_user = ... # type: Text
@@ -71,6 +72,11 @@ class BaseRequest:
7172
is_multiprocess = ... # type: bool
7273
is_run_once = ... # type: bool
7374

75+
# These are not preset at runtime but we add them since monkeypatching this
76+
# class is quite common.
77+
def __setattr__(self, name: str, value: Any): ...
78+
def __getattr__(self, name: str): ...
79+
7480
_OnCloseT = TypeVar('_OnCloseT', bound=Callable[[], Any])
7581
_SelfT = TypeVar('_SelfT', bound=BaseResponse)
7682

0 commit comments

Comments
 (0)