massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stubs / Flask / flask / app.pyi
1 from datetime import timedelta
2 from logging import Logger
3 from types import TracebackType
4 from typing import (
5     Any,
6     ByteString,
7     Callable,
8     ContextManager,
9     Dict,
10     Iterable,
11     List,
12     NoReturn,
13     Optional,
14     Text,
15     Tuple,
16     Type,
17     TypeVar,
18     Union,
19 )
20
21 from .blueprints import Blueprint
22 from .config import Config
23 from .ctx import AppContext, RequestContext
24 from .helpers import _PackageBoundObject
25 from .testing import FlaskClient
26 from .wrappers import Response
27
28 def setupmethod(f: Any): ...
29
30 _T = TypeVar("_T")
31
32 _ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]]
33 _StartResponse = Callable[[str, List[Tuple[str, str]], Optional[_ExcInfo]], Callable[[bytes], Any]]
34 _WSGICallable = Callable[[Dict[Text, Any], _StartResponse], Iterable[bytes]]
35
36 _Status = Union[str, int]
37 _Headers = Union[Dict[Any, Any], List[Tuple[Any, Any]]]
38 _Body = Union[Text, ByteString, Dict[Text, Any], Response, _WSGICallable]
39 _ViewFuncReturnType = Union[_Body, Tuple[_Body, _Status, _Headers], Tuple[_Body, _Status], Tuple[_Body, _Headers]]
40
41 _ViewFunc = Union[Callable[..., NoReturn], Callable[..., _ViewFuncReturnType]]
42 _VT = TypeVar("_VT", bound=_ViewFunc)
43
44 class Flask(_PackageBoundObject):
45     request_class: type = ...
46     response_class: type = ...
47     jinja_environment: type = ...
48     app_ctx_globals_class: type = ...
49     config_class: Type[Config] = ...
50     testing: Any = ...
51     secret_key: Text | bytes | None = ...
52     session_cookie_name: Any = ...
53     permanent_session_lifetime: timedelta = ...
54     send_file_max_age_default: timedelta = ...
55     use_x_sendfile: Any = ...
56     json_encoder: Any = ...
57     json_decoder: Any = ...
58     jinja_options: Any = ...
59     default_config: Any = ...
60     url_rule_class: type = ...
61     test_client_class: type = ...
62     test_cli_runner_class: type = ...
63     session_interface: Any = ...
64     import_name: str = ...
65     template_folder: str = ...
66     root_path: str | Text = ...
67     static_url_path: Any = ...
68     static_folder: str | None = ...
69     instance_path: str | Text = ...
70     config: Config = ...
71     view_functions: Any = ...
72     error_handler_spec: Any = ...
73     url_build_error_handlers: Any = ...
74     before_request_funcs: dict[str | None, list[Callable[[], Any]]] = ...
75     before_first_request_funcs: list[Callable[[], None]] = ...
76     after_request_funcs: dict[str | None, list[Callable[[Response], Response]]] = ...
77     teardown_request_funcs: dict[str | None, list[Callable[[Exception | None], Any]]] = ...
78     teardown_appcontext_funcs: list[Callable[[Exception | None], Any]] = ...
79     url_value_preprocessors: Any = ...
80     url_default_functions: Any = ...
81     template_context_processors: Any = ...
82     shell_context_processors: Any = ...
83     blueprints: Any = ...
84     extensions: Any = ...
85     url_map: Any = ...
86     subdomain_matching: Any = ...
87     cli: Any = ...
88     def __init__(
89         self,
90         import_name: str,
91         static_url_path: str | None = ...,
92         static_folder: str | None = ...,
93         static_host: str | None = ...,
94         host_matching: bool = ...,
95         subdomain_matching: bool = ...,
96         template_folder: str = ...,
97         instance_path: str | None = ...,
98         instance_relative_config: bool = ...,
99         root_path: str | None = ...,
100     ) -> None: ...
101     @property
102     def name(self) -> str: ...
103     @property
104     def propagate_exceptions(self) -> bool: ...
105     @property
106     def preserve_context_on_exception(self): ...
107     @property
108     def logger(self) -> Logger: ...
109     @property
110     def jinja_env(self): ...
111     @property
112     def got_first_request(self) -> bool: ...
113     def make_config(self, instance_relative: bool = ...): ...
114     def auto_find_instance_path(self): ...
115     def open_instance_resource(self, resource: str | Text, mode: str = ...): ...
116     templates_auto_reload: Any = ...
117     def create_jinja_environment(self): ...
118     def create_global_jinja_loader(self): ...
119     def select_jinja_autoescape(self, filename: Any): ...
120     def update_template_context(self, context: Any) -> None: ...
121     def make_shell_context(self): ...
122     env: str | None = ...
123     debug: bool = ...
124     def run(
125         self,
126         host: str | None = ...,
127         port: int | str | None = ...,
128         debug: bool | None = ...,
129         load_dotenv: bool = ...,
130         **options: Any,
131     ) -> None: ...
132     def test_client(self, use_cookies: bool = ..., **kwargs: Any) -> FlaskClient[Response]: ...
133     def test_cli_runner(self, **kwargs: Any): ...
134     def open_session(self, request: Any): ...
135     def save_session(self, session: Any, response: Any): ...
136     def make_null_session(self): ...
137     def register_blueprint(self, blueprint: Blueprint, **options: Any) -> None: ...
138     def iter_blueprints(self): ...
139     def add_url_rule(
140         self,
141         rule: str,
142         endpoint: str | None = ...,
143         view_func: _ViewFunc = ...,
144         provide_automatic_options: bool | None = ...,
145         **options: Any,
146     ) -> None: ...
147     def route(self, rule: str, **options: Any) -> Callable[[_VT], _VT]: ...
148     def endpoint(self, endpoint: str) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
149     def errorhandler(self, code_or_exception: int | Type[Exception]) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
150     def register_error_handler(self, code_or_exception: int | Type[Exception], f: Callable[..., Any]) -> None: ...
151     def template_filter(self, name: Any | None = ...): ...
152     def add_template_filter(self, f: Any, name: Any | None = ...) -> None: ...
153     def template_test(self, name: Any | None = ...): ...
154     def add_template_test(self, f: Any, name: Any | None = ...) -> None: ...
155     def template_global(self, name: Any | None = ...): ...
156     def add_template_global(self, f: Any, name: Any | None = ...) -> None: ...
157     def before_request(self, f: Callable[[], _T]) -> Callable[[], _T]: ...
158     def before_first_request(self, f: Callable[[], _T]) -> Callable[[], _T]: ...
159     def after_request(self, f: Callable[[Response], Response]) -> Callable[[Response], Response]: ...
160     def teardown_request(self, f: Callable[[Exception | None], _T]) -> Callable[[Exception | None], _T]: ...
161     def teardown_appcontext(self, f: Callable[[Exception | None], _T]) -> Callable[[Exception | None], _T]: ...
162     def context_processor(self, f: Any): ...
163     def shell_context_processor(self, f: Any): ...
164     def url_value_preprocessor(self, f: Any): ...
165     def url_defaults(self, f: Any): ...
166     def handle_http_exception(self, e: Any): ...
167     def trap_http_exception(self, e: Any): ...
168     def handle_user_exception(self, e: Any): ...
169     def handle_exception(self, e: Any): ...
170     def log_exception(self, exc_info: Any) -> None: ...
171     def raise_routing_exception(self, request: Any) -> None: ...
172     def dispatch_request(self): ...
173     def full_dispatch_request(self): ...
174     def finalize_request(self, rv: Any, from_error_handler: bool = ...): ...
175     def try_trigger_before_first_request_functions(self): ...
176     def make_default_options_response(self): ...
177     def should_ignore_error(self, error: Any): ...
178     def make_response(self, rv: Any): ...
179     def create_url_adapter(self, request: Any): ...
180     def inject_url_defaults(self, endpoint: Any, values: Any) -> None: ...
181     def handle_url_build_error(self, error: Any, endpoint: Any, values: Any): ...
182     def preprocess_request(self): ...
183     def process_response(self, response: Any): ...
184     def do_teardown_request(self, exc: Any = ...) -> None: ...
185     def do_teardown_appcontext(self, exc: Any = ...) -> None: ...
186     def app_context(self) -> AppContext: ...
187     def request_context(self, environ: Any): ...
188     def test_request_context(self, *args: Any, **kwargs: Any) -> ContextManager[RequestContext]: ...
189     def wsgi_app(self, environ: Any, start_response: Any): ...
190     def __call__(self, environ: Any, start_response: Any): ...
191     # These are not preset at runtime but we add them since monkeypatching this
192     # class is quite common.
193     def __setattr__(self, name: str, value: Any): ...
194     def __getattr__(self, name: str): ...