Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions third_party/2and3/flask/app.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,51 @@ from .signals import appcontext_tearing_down, got_request_exception, request_fin
from .templating import DispatchingJinjaLoader, Environment
from .wrappers import Request, Response
from .testing import FlaskClient
from typing import Any, Callable, ContextManager, Dict, List, Optional, Type, TypeVar, Union, Text
from types import TracebackType
from typing import (
Any,
Callable,
ContextManager,
Dict,
List,
Optional,
Type,
TypeVar,
Union,
Text,
Tuple,
NoReturn,
Iterable,
ByteString
)
from datetime import timedelta

def setupmethod(f: Any): ...

_T = TypeVar('_T')


_ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]]
_StartResponse = Callable[[str, List[Tuple[str, str]], Optional[_ExcInfo]], Callable[[bytes], Any]]
_WSGICallable = Callable[[Dict[Text, Any], _StartResponse], Iterable[bytes]]

_Status = Union[str, int]
_Headers = Union[Dict[Any, Any], List[Tuple[Any, Any]]]
_Body = Union[Text, ByteString, Response, _WSGICallable]

_ViewFunc = Union[
Callable[..., Text],
Callable[..., ByteString],
Callable[..., NoReturn],
Callable[..., Response],
Callable[..., _WSGICallable],
Callable[..., Tuple[_Body, _Status, _Headers]],
Callable[..., Tuple[_Body, _Status]],
Callable[..., Tuple[_Body, _Headers]]
]
_VT = TypeVar('_VT', bound=_ViewFunc)


class Flask(_PackageBoundObject):
request_class: type = ...
response_class: type = ...
Expand Down Expand Up @@ -96,8 +134,8 @@ class Flask(_PackageBoundObject):
def make_null_session(self): ...
def register_blueprint(self, blueprint: Blueprint, **options: Any) -> None: ...
def iter_blueprints(self): ...
def add_url_rule(self, rule: str, endpoint: Optional[str] = ..., view_func: Callable[..., Any] = ..., provide_automatic_options: Optional[bool] = ..., **options: Any) -> None: ...
def route(self, rule: str, **options: Any) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
def add_url_rule(self, rule: str, endpoint: Optional[str] = ..., view_func: _ViewFunc = ..., provide_automatic_options: Optional[bool] = ..., **options: Any) -> None: ...
def route(self, rule: str, **options: Any) -> Callable[[_VT], _VT]: ...
def endpoint(self, endpoint: str) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
def errorhandler(self, code_or_exception: Union[int, Type[Exception]]) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
def register_error_handler(self, code_or_exception: Union[int, Type[Exception]], f: Callable[..., Any]) -> None: ...
Expand Down
8 changes: 5 additions & 3 deletions third_party/2and3/flask/blueprints.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from .helpers import _PackageBoundObject
from .app import _ViewFunc
from typing import Any, Callable, Optional, Type, TypeVar, Union

_T = TypeVar('_T')
_VT = TypeVar('_VT', bound=_ViewFunc)

class BlueprintSetupState:
app: Any = ...
Expand All @@ -16,7 +18,7 @@ class BlueprintSetupState:
url_prefix: Any = ...
url_defaults: Any = ...
def __init__(self, blueprint: Any, app: Any, options: Any, first_registration: Any) -> None: ...
def add_url_rule(self, rule: str, endpoint: Optional[str] = ..., view_func: Callable[..., Any] = ..., **options: Any) -> None: ...
def add_url_rule(self, rule: str, endpoint: Optional[str] = ..., view_func: _ViewFunc = ..., **options: Any) -> None: ...

class Blueprint(_PackageBoundObject):
warn_on_modifications: bool = ...
Expand All @@ -37,8 +39,8 @@ class Blueprint(_PackageBoundObject):
def record_once(self, func: Any): ...
def make_setup_state(self, app: Any, options: Any, first_registration: bool = ...): ...
def register(self, app: Any, options: Any, first_registration: bool = ...) -> None: ...
def route(self, rule: str, **options: Any) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ...
def add_url_rule(self, rule: str, endpoint: Optional[str] = ..., view_func: Callable[..., Any] = ..., **options: Any) -> None: ...
def route(self, rule: str, **options: Any) -> Callable[[_VT], _VT]: ...
def add_url_rule(self, rule: str, endpoint: Optional[str] = ..., view_func: _ViewFunc = ..., **options: Any) -> None: ...
def endpoint(self, endpoint: str) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
def app_template_filter(self, name: Optional[Any] = ...): ...
def add_app_template_filter(self, f: Any, name: Optional[Any] = ...) -> None: ...
Expand Down
9 changes: 6 additions & 3 deletions third_party/2and3/flask/templating.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .globals import _app_ctx_stack, _request_ctx_stack
from .signals import before_render_template, template_rendered
from jinja2 import BaseLoader, Environment as BaseEnvironment
from typing import Any
from typing import Any, Text, Iterable, Union

class Environment(BaseEnvironment):
app: Any = ...
Expand All @@ -17,5 +17,8 @@ class DispatchingJinjaLoader(BaseLoader):
def get_source(self, environment: Any, template: Any): ...
def list_templates(self): ...

def render_template(template_name_or_list: Any, **context: Any): ...
def render_template_string(source: Any, **context: Any): ...
def render_template(
template_name_or_list: Union[Text, Iterable[Text]],
**context: Any
) -> Text: ...
def render_template_string(source: Text, **context: Any) -> Text: ...