mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-16 06:52:02 +08:00
Re-organize directory structure (#4971)
See discussion in #2491 Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
This commit is contained in:
3
stubs/Flask/METADATA.toml
Normal file
3
stubs/Flask/METADATA.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
version = "0.1"
|
||||
python2 = true
|
||||
requires = ["types-Jinja2", "types-Werkzeug", "types-click"]
|
||||
41
stubs/Flask/flask/__init__.pyi
Normal file
41
stubs/Flask/flask/__init__.pyi
Normal file
@@ -0,0 +1,41 @@
|
||||
from jinja2 import Markup as Markup, escape as escape
|
||||
from werkzeug.exceptions import abort as abort
|
||||
from werkzeug.utils import redirect as redirect
|
||||
|
||||
from .app import Flask as Flask
|
||||
from .blueprints import Blueprint as Blueprint
|
||||
from .config import Config as Config
|
||||
from .ctx import (
|
||||
after_this_request as after_this_request,
|
||||
copy_current_request_context as copy_current_request_context,
|
||||
has_app_context as has_app_context,
|
||||
has_request_context as has_request_context,
|
||||
)
|
||||
from .globals import current_app as current_app, g as g, request as request, session as session
|
||||
from .helpers import (
|
||||
flash as flash,
|
||||
get_flashed_messages as get_flashed_messages,
|
||||
get_template_attribute as get_template_attribute,
|
||||
make_response as make_response,
|
||||
safe_join as safe_join,
|
||||
send_file as send_file,
|
||||
send_from_directory as send_from_directory,
|
||||
stream_with_context as stream_with_context,
|
||||
url_for as url_for,
|
||||
)
|
||||
from .json import jsonify as jsonify
|
||||
from .signals import (
|
||||
appcontext_popped as appcontext_popped,
|
||||
appcontext_pushed as appcontext_pushed,
|
||||
appcontext_tearing_down as appcontext_tearing_down,
|
||||
before_render_template as before_render_template,
|
||||
got_request_exception as got_request_exception,
|
||||
message_flashed as message_flashed,
|
||||
request_finished as request_finished,
|
||||
request_started as request_started,
|
||||
request_tearing_down as request_tearing_down,
|
||||
signals_available as signals_available,
|
||||
template_rendered as template_rendered,
|
||||
)
|
||||
from .templating import render_template as render_template, render_template_string as render_template_string
|
||||
from .wrappers import Request as Request, Response as Response
|
||||
195
stubs/Flask/flask/app.pyi
Normal file
195
stubs/Flask/flask/app.pyi
Normal file
@@ -0,0 +1,195 @@
|
||||
from datetime import timedelta
|
||||
from types import TracebackType
|
||||
from typing import (
|
||||
Any,
|
||||
ByteString,
|
||||
Callable,
|
||||
ContextManager,
|
||||
Dict,
|
||||
Iterable,
|
||||
List,
|
||||
NoReturn,
|
||||
Optional,
|
||||
Text,
|
||||
Tuple,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
from .blueprints import Blueprint
|
||||
from .config import Config
|
||||
from .ctx import AppContext, RequestContext
|
||||
from .helpers import _PackageBoundObject
|
||||
from .testing import FlaskClient
|
||||
from .wrappers import Response
|
||||
|
||||
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, Dict[Text, Any], Response, _WSGICallable]
|
||||
_ViewFuncReturnType = Union[_Body, Tuple[_Body, _Status, _Headers], Tuple[_Body, _Status], Tuple[_Body, _Headers]]
|
||||
|
||||
_ViewFunc = Union[Callable[..., NoReturn], Callable[..., _ViewFuncReturnType]]
|
||||
_VT = TypeVar("_VT", bound=_ViewFunc)
|
||||
|
||||
class Flask(_PackageBoundObject):
|
||||
request_class: type = ...
|
||||
response_class: type = ...
|
||||
jinja_environment: type = ...
|
||||
app_ctx_globals_class: type = ...
|
||||
config_class: Type[Config] = ...
|
||||
testing: Any = ...
|
||||
secret_key: Union[Text, bytes, None] = ...
|
||||
session_cookie_name: Any = ...
|
||||
permanent_session_lifetime: timedelta = ...
|
||||
send_file_max_age_default: timedelta = ...
|
||||
use_x_sendfile: Any = ...
|
||||
json_encoder: Any = ...
|
||||
json_decoder: Any = ...
|
||||
jinja_options: Any = ...
|
||||
default_config: Any = ...
|
||||
url_rule_class: type = ...
|
||||
test_client_class: type = ...
|
||||
test_cli_runner_class: type = ...
|
||||
session_interface: Any = ...
|
||||
import_name: str = ...
|
||||
template_folder: str = ...
|
||||
root_path: Union[str, Text] = ...
|
||||
static_url_path: Any = ...
|
||||
static_folder: Optional[str] = ...
|
||||
instance_path: Union[str, Text] = ...
|
||||
config: Config = ...
|
||||
view_functions: Any = ...
|
||||
error_handler_spec: Any = ...
|
||||
url_build_error_handlers: Any = ...
|
||||
before_request_funcs: Dict[Optional[str], List[Callable[[], Any]]] = ...
|
||||
before_first_request_funcs: List[Callable[[], None]] = ...
|
||||
after_request_funcs: Dict[Optional[str], List[Callable[[Response], Response]]] = ...
|
||||
teardown_request_funcs: Dict[Optional[str], List[Callable[[Optional[Exception]], Any]]] = ...
|
||||
teardown_appcontext_funcs: List[Callable[[Optional[Exception]], Any]] = ...
|
||||
url_value_preprocessors: Any = ...
|
||||
url_default_functions: Any = ...
|
||||
template_context_processors: Any = ...
|
||||
shell_context_processors: Any = ...
|
||||
blueprints: Any = ...
|
||||
extensions: Any = ...
|
||||
url_map: Any = ...
|
||||
subdomain_matching: Any = ...
|
||||
cli: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
import_name: str,
|
||||
static_url_path: Optional[str] = ...,
|
||||
static_folder: Optional[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: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
@property
|
||||
def propagate_exceptions(self) -> bool: ...
|
||||
@property
|
||||
def preserve_context_on_exception(self): ...
|
||||
@property
|
||||
def logger(self): ...
|
||||
@property
|
||||
def jinja_env(self): ...
|
||||
@property
|
||||
def got_first_request(self) -> bool: ...
|
||||
def make_config(self, instance_relative: bool = ...): ...
|
||||
def auto_find_instance_path(self): ...
|
||||
def open_instance_resource(self, resource: Union[str, Text], mode: str = ...): ...
|
||||
templates_auto_reload: Any = ...
|
||||
def create_jinja_environment(self): ...
|
||||
def create_global_jinja_loader(self): ...
|
||||
def select_jinja_autoescape(self, filename: Any): ...
|
||||
def update_template_context(self, context: Any) -> None: ...
|
||||
def make_shell_context(self): ...
|
||||
env: Optional[str] = ...
|
||||
debug: bool = ...
|
||||
def run(
|
||||
self,
|
||||
host: Optional[str] = ...,
|
||||
port: Optional[Union[int, str]] = ...,
|
||||
debug: Optional[bool] = ...,
|
||||
load_dotenv: bool = ...,
|
||||
**options: Any,
|
||||
) -> None: ...
|
||||
def test_client(self, use_cookies: bool = ..., **kwargs: Any) -> FlaskClient[Response]: ...
|
||||
def test_cli_runner(self, **kwargs: Any): ...
|
||||
def open_session(self, request: Any): ...
|
||||
def save_session(self, session: Any, response: Any): ...
|
||||
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: _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: ...
|
||||
def template_filter(self, name: Optional[Any] = ...): ...
|
||||
def add_template_filter(self, f: Any, name: Optional[Any] = ...) -> None: ...
|
||||
def template_test(self, name: Optional[Any] = ...): ...
|
||||
def add_template_test(self, f: Any, name: Optional[Any] = ...) -> None: ...
|
||||
def template_global(self, name: Optional[Any] = ...): ...
|
||||
def add_template_global(self, f: Any, name: Optional[Any] = ...) -> None: ...
|
||||
def before_request(self, f: Callable[[], _T]) -> Callable[[], _T]: ...
|
||||
def before_first_request(self, f: Callable[[], _T]) -> Callable[[], _T]: ...
|
||||
def after_request(self, f: Callable[[Response], Response]) -> Callable[[Response], Response]: ...
|
||||
def teardown_request(self, f: Callable[[Optional[Exception]], _T]) -> Callable[[Optional[Exception]], _T]: ...
|
||||
def teardown_appcontext(self, f: Callable[[Optional[Exception]], _T]) -> Callable[[Optional[Exception]], _T]: ...
|
||||
def context_processor(self, f: Any): ...
|
||||
def shell_context_processor(self, f: Any): ...
|
||||
def url_value_preprocessor(self, f: Any): ...
|
||||
def url_defaults(self, f: Any): ...
|
||||
def handle_http_exception(self, e: Any): ...
|
||||
def trap_http_exception(self, e: Any): ...
|
||||
def handle_user_exception(self, e: Any): ...
|
||||
def handle_exception(self, e: Any): ...
|
||||
def log_exception(self, exc_info: Any) -> None: ...
|
||||
def raise_routing_exception(self, request: Any) -> None: ...
|
||||
def dispatch_request(self): ...
|
||||
def full_dispatch_request(self): ...
|
||||
def finalize_request(self, rv: Any, from_error_handler: bool = ...): ...
|
||||
def try_trigger_before_first_request_functions(self): ...
|
||||
def make_default_options_response(self): ...
|
||||
def should_ignore_error(self, error: Any): ...
|
||||
def make_response(self, rv: Any): ...
|
||||
def create_url_adapter(self, request: Any): ...
|
||||
def inject_url_defaults(self, endpoint: Any, values: Any) -> None: ...
|
||||
def handle_url_build_error(self, error: Any, endpoint: Any, values: Any): ...
|
||||
def preprocess_request(self): ...
|
||||
def process_response(self, response: Any): ...
|
||||
def do_teardown_request(self, exc: Any = ...) -> None: ...
|
||||
def do_teardown_appcontext(self, exc: Any = ...) -> None: ...
|
||||
def app_context(self) -> AppContext: ...
|
||||
def request_context(self, environ: Any): ...
|
||||
def test_request_context(self, *args: Any, **kwargs: Any) -> ContextManager[RequestContext]: ...
|
||||
def wsgi_app(self, environ: Any, start_response: Any): ...
|
||||
def __call__(self, environ: Any, start_response: Any): ...
|
||||
# These are not preset at runtime but we add them since monkeypatching this
|
||||
# class is quite common.
|
||||
def __setattr__(self, name: str, value: Any): ...
|
||||
def __getattr__(self, name: str): ...
|
||||
80
stubs/Flask/flask/blueprints.pyi
Normal file
80
stubs/Flask/flask/blueprints.pyi
Normal file
@@ -0,0 +1,80 @@
|
||||
from typing import Any, Callable, Optional, Type, TypeVar, Union
|
||||
|
||||
from .app import _ViewFunc
|
||||
from .helpers import _PackageBoundObject
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_VT = TypeVar("_VT", bound=_ViewFunc)
|
||||
|
||||
class _Sentinel(object): ...
|
||||
|
||||
class BlueprintSetupState:
|
||||
app: Any = ...
|
||||
blueprint: Any = ...
|
||||
options: Any = ...
|
||||
first_registration: Any = ...
|
||||
subdomain: Any = ...
|
||||
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: _ViewFunc = ..., **options: Any) -> None: ...
|
||||
|
||||
class Blueprint(_PackageBoundObject):
|
||||
warn_on_modifications: bool = ...
|
||||
json_encoder: Any = ...
|
||||
json_decoder: Any = ...
|
||||
import_name: str = ...
|
||||
template_folder: Optional[str] = ...
|
||||
root_path: str = ...
|
||||
name: str = ...
|
||||
url_prefix: Optional[str] = ...
|
||||
subdomain: Optional[str] = ...
|
||||
static_folder: Optional[str] = ...
|
||||
static_url_path: Optional[str] = ...
|
||||
deferred_functions: Any = ...
|
||||
url_values_defaults: Any = ...
|
||||
cli_group: Union[Optional[str], _Sentinel] = ...
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
import_name: str,
|
||||
static_folder: Optional[str] = ...,
|
||||
static_url_path: Optional[str] = ...,
|
||||
template_folder: Optional[str] = ...,
|
||||
url_prefix: Optional[str] = ...,
|
||||
subdomain: Optional[str] = ...,
|
||||
url_defaults: Optional[Any] = ...,
|
||||
root_path: Optional[str] = ...,
|
||||
cli_group: Union[Optional[str], _Sentinel] = ...,
|
||||
) -> None: ...
|
||||
def record(self, func: Any) -> None: ...
|
||||
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[[_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: ...
|
||||
def app_template_test(self, name: Optional[Any] = ...): ...
|
||||
def add_app_template_test(self, f: Any, name: Optional[Any] = ...) -> None: ...
|
||||
def app_template_global(self, name: Optional[Any] = ...): ...
|
||||
def add_app_template_global(self, f: Any, name: Optional[Any] = ...) -> None: ...
|
||||
def before_request(self, f: Any): ...
|
||||
def before_app_request(self, f: Any): ...
|
||||
def before_app_first_request(self, f: Any): ...
|
||||
def after_request(self, f: Any): ...
|
||||
def after_app_request(self, f: Any): ...
|
||||
def teardown_request(self, f: Any): ...
|
||||
def teardown_app_request(self, f: Any): ...
|
||||
def context_processor(self, f: Any): ...
|
||||
def app_context_processor(self, f: Any): ...
|
||||
def app_errorhandler(self, code: Any): ...
|
||||
def url_value_preprocessor(self, f: Any): ...
|
||||
def url_defaults(self, f: Any): ...
|
||||
def app_url_value_preprocessor(self, f: Any): ...
|
||||
def app_url_defaults(self, f: Any): ...
|
||||
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: ...
|
||||
68
stubs/Flask/flask/cli.pyi
Normal file
68
stubs/Flask/flask/cli.pyi
Normal file
@@ -0,0 +1,68 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
import click
|
||||
|
||||
class NoAppException(click.UsageError): ...
|
||||
|
||||
def find_best_app(script_info: Any, module: Any): ...
|
||||
def call_factory(script_info: Any, app_factory: Any, arguments: Any = ...): ...
|
||||
def find_app_by_string(script_info: Any, module: Any, app_name: Any): ...
|
||||
def prepare_import(path: Any): ...
|
||||
def locate_app(script_info: Any, module_name: Any, app_name: Any, raise_if_not_found: bool = ...): ...
|
||||
def get_version(ctx: Any, param: Any, value: Any): ...
|
||||
|
||||
version_option: Any
|
||||
|
||||
class DispatchingApp:
|
||||
loader: Any = ...
|
||||
def __init__(self, loader: Any, use_eager_loading: bool = ...) -> None: ...
|
||||
def __call__(self, environ: Any, start_response: Any): ...
|
||||
|
||||
class ScriptInfo:
|
||||
app_import_path: Any = ...
|
||||
create_app: Any = ...
|
||||
data: Any = ...
|
||||
def __init__(self, app_import_path: Optional[Any] = ..., create_app: Optional[Any] = ...) -> None: ...
|
||||
def load_app(self): ...
|
||||
|
||||
pass_script_info: Any
|
||||
|
||||
def with_appcontext(f: Any): ...
|
||||
|
||||
class AppGroup(click.Group):
|
||||
def command(self, *args: Any, **kwargs: Any): ...
|
||||
def group(self, *args: Any, **kwargs: Any): ...
|
||||
|
||||
class FlaskGroup(AppGroup):
|
||||
create_app: Any = ...
|
||||
load_dotenv: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
add_default_commands: bool = ...,
|
||||
create_app: Optional[Any] = ...,
|
||||
add_version_option: bool = ...,
|
||||
load_dotenv: bool = ...,
|
||||
**extra: Any,
|
||||
) -> None: ...
|
||||
def get_command(self, ctx: Any, name: Any): ...
|
||||
def list_commands(self, ctx: Any): ...
|
||||
def main(self, *args: Any, **kwargs: Any): ...
|
||||
|
||||
def load_dotenv(path: Optional[Any] = ...): ...
|
||||
def show_server_banner(env: Any, debug: Any, app_import_path: Any, eager_loading: Any): ...
|
||||
|
||||
class CertParamType(click.ParamType):
|
||||
name: str = ...
|
||||
path_type: Any = ...
|
||||
def __init__(self) -> None: ...
|
||||
def convert(self, value: Any, param: Any, ctx: Any): ...
|
||||
|
||||
def run_command(
|
||||
info: Any, host: Any, port: Any, reload: Any, debugger: Any, eager_loading: Any, with_threads: Any, cert: Any
|
||||
) -> None: ...
|
||||
def shell_command() -> None: ...
|
||||
def routes_command(sort: Any, all_methods: Any): ...
|
||||
|
||||
cli: Any
|
||||
|
||||
def main(as_module: bool = ...) -> None: ...
|
||||
18
stubs/Flask/flask/config.pyi
Normal file
18
stubs/Flask/flask/config.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
class ConfigAttribute:
|
||||
__name__: Any = ...
|
||||
get_converter: Any = ...
|
||||
def __init__(self, name: Any, get_converter: Optional[Any] = ...) -> None: ...
|
||||
def __get__(self, obj: Any, type: Optional[Any] = ...): ...
|
||||
def __set__(self, obj: Any, value: Any) -> None: ...
|
||||
|
||||
class Config(Dict[str, Any]):
|
||||
root_path: Any = ...
|
||||
def __init__(self, root_path: Any, defaults: Optional[Any] = ...) -> None: ...
|
||||
def from_envvar(self, variable_name: Any, silent: bool = ...): ...
|
||||
def from_pyfile(self, filename: Any, silent: bool = ...): ...
|
||||
def from_object(self, obj: Any) -> None: ...
|
||||
def from_json(self, filename: Any, silent: bool = ...): ...
|
||||
def from_mapping(self, *mapping: Any, **kwargs: Any): ...
|
||||
def get_namespace(self, namespace: Any, lowercase: bool = ..., trim_namespace: bool = ...): ...
|
||||
40
stubs/Flask/flask/ctx.pyi
Normal file
40
stubs/Flask/flask/ctx.pyi
Normal file
@@ -0,0 +1,40 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
class _AppCtxGlobals:
|
||||
def get(self, name: Any, default: Optional[Any] = ...): ...
|
||||
def pop(self, name: Any, default: Any = ...): ...
|
||||
def setdefault(self, name: Any, default: Optional[Any] = ...): ...
|
||||
def __contains__(self, item: Any): ...
|
||||
def __iter__(self): ...
|
||||
|
||||
def after_this_request(f: Any): ...
|
||||
def copy_current_request_context(f: Any): ...
|
||||
def has_request_context(): ...
|
||||
def has_app_context(): ...
|
||||
|
||||
class AppContext:
|
||||
app: Any = ...
|
||||
url_adapter: Any = ...
|
||||
g: Any = ...
|
||||
def __init__(self, app: Any) -> None: ...
|
||||
def push(self) -> None: ...
|
||||
def pop(self, exc: Any = ...) -> None: ...
|
||||
def __enter__(self): ...
|
||||
def __exit__(self, exc_type: Any, exc_value: Any, tb: Any) -> None: ...
|
||||
|
||||
class RequestContext:
|
||||
app: Any = ...
|
||||
request: Any = ...
|
||||
url_adapter: Any = ...
|
||||
flashes: Any = ...
|
||||
session: Any = ...
|
||||
preserved: bool = ...
|
||||
def __init__(self, app: Any, environ: Any, request: Optional[Any] = ...) -> None: ...
|
||||
g: Any = ...
|
||||
def copy(self): ...
|
||||
def match_request(self) -> None: ...
|
||||
def push(self) -> None: ...
|
||||
def pop(self, exc: Any = ...) -> None: ...
|
||||
def auto_pop(self, exc: Any) -> None: ...
|
||||
def __enter__(self): ...
|
||||
def __exit__(self, exc_type: Any, exc_value: Any, tb: Any) -> None: ...
|
||||
14
stubs/Flask/flask/debughelpers.pyi
Normal file
14
stubs/Flask/flask/debughelpers.pyi
Normal file
@@ -0,0 +1,14 @@
|
||||
from typing import Any
|
||||
|
||||
class UnexpectedUnicodeError(AssertionError, UnicodeError): ...
|
||||
|
||||
class DebugFilesKeyError(KeyError, AssertionError):
|
||||
msg: Any = ...
|
||||
def __init__(self, request: Any, key: Any) -> None: ...
|
||||
|
||||
class FormDataRoutingRedirect(AssertionError):
|
||||
def __init__(self, request: Any) -> None: ...
|
||||
|
||||
def attach_enctype_error_multidict(request: Any): ...
|
||||
def explain_template_loading_attempts(app: Any, template: Any, attempts: Any) -> None: ...
|
||||
def explain_ignored_app_run() -> None: ...
|
||||
16
stubs/Flask/flask/globals.pyi
Normal file
16
stubs/Flask/flask/globals.pyi
Normal file
@@ -0,0 +1,16 @@
|
||||
from typing import Any
|
||||
|
||||
from werkzeug.local import LocalStack
|
||||
|
||||
from .app import Flask
|
||||
from .wrappers import Request
|
||||
|
||||
class _FlaskLocalProxy(Flask):
|
||||
def _get_current_object(self) -> Flask: ...
|
||||
|
||||
_request_ctx_stack: LocalStack
|
||||
_app_ctx_stack: LocalStack
|
||||
current_app: _FlaskLocalProxy
|
||||
request: Request
|
||||
session: Any
|
||||
g: Any
|
||||
55
stubs/Flask/flask/helpers.pyi
Normal file
55
stubs/Flask/flask/helpers.pyi
Normal file
@@ -0,0 +1,55 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from .cli import AppGroup
|
||||
from .wrappers import Response
|
||||
|
||||
def get_env(): ...
|
||||
def get_debug_flag(): ...
|
||||
def get_load_dotenv(default: bool = ...): ...
|
||||
def stream_with_context(generator_or_function: Any): ...
|
||||
def make_response(*args: Any) -> Response: ...
|
||||
def url_for(endpoint: str, **values: Any) -> str: ...
|
||||
def get_template_attribute(template_name: Any, attribute: Any): ...
|
||||
def flash(message: Any, category: str = ...) -> None: ...
|
||||
def get_flashed_messages(with_categories: bool = ..., category_filter: Any = ...): ...
|
||||
def send_file(
|
||||
filename_or_fp: Any,
|
||||
mimetype: Optional[Any] = ...,
|
||||
as_attachment: bool = ...,
|
||||
attachment_filename: Optional[Any] = ...,
|
||||
add_etags: bool = ...,
|
||||
cache_timeout: Optional[Any] = ...,
|
||||
conditional: bool = ...,
|
||||
last_modified: Optional[Any] = ...,
|
||||
) -> Response: ...
|
||||
def safe_join(directory: Any, *pathnames: Any): ...
|
||||
def send_from_directory(directory: Any, filename: Any, **options: Any) -> Response: ...
|
||||
def get_root_path(import_name: Any): ...
|
||||
def find_package(import_name: Any): ...
|
||||
|
||||
class locked_cached_property:
|
||||
__name__: Any = ...
|
||||
__module__: Any = ...
|
||||
__doc__: Any = ...
|
||||
func: Any = ...
|
||||
lock: Any = ...
|
||||
def __init__(self, func: Any, name: Optional[Any] = ..., doc: Optional[Any] = ...) -> None: ...
|
||||
def __get__(self, obj: Any, type: Optional[Any] = ...): ...
|
||||
|
||||
class _PackageBoundObject:
|
||||
import_name: Any = ...
|
||||
template_folder: Any = ...
|
||||
root_path: Any = ...
|
||||
cli: AppGroup = ...
|
||||
def __init__(self, import_name: Any, template_folder: Optional[Any] = ..., root_path: Optional[Any] = ...) -> None: ...
|
||||
static_folder: Any = ...
|
||||
static_url_path: Any = ...
|
||||
@property
|
||||
def has_static_folder(self): ...
|
||||
def jinja_loader(self): ...
|
||||
def get_send_file_max_age(self, filename: Any): ...
|
||||
def send_static_file(self, filename: Any) -> Response: ...
|
||||
def open_resource(self, resource: Any, mode: str = ...): ...
|
||||
|
||||
def total_seconds(td: Any): ...
|
||||
def is_ip(value: Any): ...
|
||||
19
stubs/Flask/flask/json/__init__.pyi
Normal file
19
stubs/Flask/flask/json/__init__.pyi
Normal file
@@ -0,0 +1,19 @@
|
||||
import json as _json
|
||||
from typing import Any
|
||||
|
||||
from jinja2 import Markup
|
||||
|
||||
class JSONEncoder(_json.JSONEncoder):
|
||||
def default(self, o: Any): ...
|
||||
|
||||
class JSONDecoder(_json.JSONDecoder): ...
|
||||
|
||||
def detect_encoding(data: bytes) -> str: ... # undocumented
|
||||
def dumps(obj: Any, **kwargs: Any): ...
|
||||
def dump(obj: Any, fp: Any, **kwargs: Any) -> None: ...
|
||||
def loads(s: Any, **kwargs: Any): ...
|
||||
def load(fp: Any, **kwargs: Any): ...
|
||||
def htmlsafe_dumps(obj: Any, **kwargs: Any): ...
|
||||
def htmlsafe_dump(obj: Any, fp: Any, **kwargs: Any) -> None: ...
|
||||
def jsonify(*args: Any, **kwargs: Any): ...
|
||||
def tojson_filter(obj: Any, **kwargs: Any) -> Markup: ... # undocumented
|
||||
67
stubs/Flask/flask/json/tag.pyi
Normal file
67
stubs/Flask/flask/json/tag.pyi
Normal file
@@ -0,0 +1,67 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
class JSONTag:
|
||||
key: Any = ...
|
||||
serializer: Any = ...
|
||||
def __init__(self, serializer: Any) -> None: ...
|
||||
def check(self, value: Any) -> None: ...
|
||||
def to_json(self, value: Any) -> None: ...
|
||||
def to_python(self, value: Any) -> None: ...
|
||||
def tag(self, value: Any): ...
|
||||
|
||||
class TagDict(JSONTag):
|
||||
key: str = ...
|
||||
def check(self, value: Any): ...
|
||||
def to_json(self, value: Any): ...
|
||||
def to_python(self, value: Any): ...
|
||||
|
||||
class PassDict(JSONTag):
|
||||
def check(self, value: Any): ...
|
||||
def to_json(self, value: Any): ...
|
||||
tag: Any = ...
|
||||
|
||||
class TagTuple(JSONTag):
|
||||
key: str = ...
|
||||
def check(self, value: Any): ...
|
||||
def to_json(self, value: Any): ...
|
||||
def to_python(self, value: Any): ...
|
||||
|
||||
class PassList(JSONTag):
|
||||
def check(self, value: Any): ...
|
||||
def to_json(self, value: Any): ...
|
||||
tag: Any = ...
|
||||
|
||||
class TagBytes(JSONTag):
|
||||
key: str = ...
|
||||
def check(self, value: Any): ...
|
||||
def to_json(self, value: Any): ...
|
||||
def to_python(self, value: Any): ...
|
||||
|
||||
class TagMarkup(JSONTag):
|
||||
key: str = ...
|
||||
def check(self, value: Any): ...
|
||||
def to_json(self, value: Any): ...
|
||||
def to_python(self, value: Any): ...
|
||||
|
||||
class TagUUID(JSONTag):
|
||||
key: str = ...
|
||||
def check(self, value: Any): ...
|
||||
def to_json(self, value: Any): ...
|
||||
def to_python(self, value: Any): ...
|
||||
|
||||
class TagDateTime(JSONTag):
|
||||
key: str = ...
|
||||
def check(self, value: Any): ...
|
||||
def to_json(self, value: Any): ...
|
||||
def to_python(self, value: Any): ...
|
||||
|
||||
class TaggedJSONSerializer:
|
||||
default_tags: Any = ...
|
||||
tags: Any = ...
|
||||
order: Any = ...
|
||||
def __init__(self) -> None: ...
|
||||
def register(self, tag_class: Any, force: bool = ..., index: Optional[Any] = ...) -> None: ...
|
||||
def tag(self, value: Any): ...
|
||||
def untag(self, value: Any): ...
|
||||
def dumps(self, value: Any): ...
|
||||
def loads(self, value: Any): ...
|
||||
8
stubs/Flask/flask/logging.pyi
Normal file
8
stubs/Flask/flask/logging.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
from typing import Any
|
||||
|
||||
def wsgi_errors_stream(): ...
|
||||
def has_level_handler(logger: Any): ...
|
||||
|
||||
default_handler: Any
|
||||
|
||||
def create_logger(app: Any): ...
|
||||
57
stubs/Flask/flask/sessions.pyi
Normal file
57
stubs/Flask/flask/sessions.pyi
Normal file
@@ -0,0 +1,57 @@
|
||||
from abc import ABCMeta
|
||||
from typing import Any, MutableMapping, Optional
|
||||
|
||||
from werkzeug.datastructures import CallbackDict
|
||||
|
||||
class SessionMixin(MutableMapping[str, Any], metaclass=ABCMeta):
|
||||
@property
|
||||
def permanent(self): ...
|
||||
@permanent.setter
|
||||
def permanent(self, value: Any) -> None: ...
|
||||
new: bool = ...
|
||||
modified: bool = ...
|
||||
accessed: bool = ...
|
||||
|
||||
class SecureCookieSession(CallbackDict[str, Any], SessionMixin):
|
||||
modified: bool = ...
|
||||
accessed: bool = ...
|
||||
def __init__(self, initial: Optional[Any] = ...) -> None: ...
|
||||
def __getitem__(self, key: Any): ...
|
||||
def get(self, key: Any, default: Optional[Any] = ...): ...
|
||||
def setdefault(self, key: Any, default: Optional[Any] = ...): ...
|
||||
|
||||
class NullSession(SecureCookieSession):
|
||||
__setitem__: Any = ...
|
||||
__delitem__: Any = ...
|
||||
clear: Any = ...
|
||||
pop: Any = ...
|
||||
popitem: Any = ...
|
||||
update: Any = ...
|
||||
setdefault: Any = ...
|
||||
|
||||
class SessionInterface:
|
||||
null_session_class: Any = ...
|
||||
pickle_based: bool = ...
|
||||
def make_null_session(self, app: Any): ...
|
||||
def is_null_session(self, obj: Any): ...
|
||||
def get_cookie_domain(self, app: Any): ...
|
||||
def get_cookie_path(self, app: Any): ...
|
||||
def get_cookie_httponly(self, app: Any): ...
|
||||
def get_cookie_secure(self, app: Any): ...
|
||||
def get_cookie_samesite(self, app: Any): ...
|
||||
def get_expiration_time(self, app: Any, session: Any): ...
|
||||
def should_set_cookie(self, app: Any, session: Any): ...
|
||||
def open_session(self, app: Any, request: Any) -> None: ...
|
||||
def save_session(self, app: Any, session: Any, response: Any) -> None: ...
|
||||
|
||||
session_json_serializer: Any
|
||||
|
||||
class SecureCookieSessionInterface(SessionInterface):
|
||||
salt: str = ...
|
||||
digest_method: Any = ...
|
||||
key_derivation: str = ...
|
||||
serializer: Any = ...
|
||||
session_class: Any = ...
|
||||
def get_signing_serializer(self, app: Any): ...
|
||||
def open_session(self, app: Any, request: Any): ...
|
||||
def save_session(self, app: Any, session: Any, response: Any): ...
|
||||
29
stubs/Flask/flask/signals.pyi
Normal file
29
stubs/Flask/flask/signals.pyi
Normal file
@@ -0,0 +1,29 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
signals_available: bool
|
||||
|
||||
class Namespace:
|
||||
def signal(self, name: Any, doc: Optional[Any] = ...): ...
|
||||
|
||||
class _FakeSignal:
|
||||
name: Any = ...
|
||||
__doc__: Any = ...
|
||||
def __init__(self, name: Any, doc: Optional[Any] = ...) -> None: ...
|
||||
send: Any = ...
|
||||
connect: Any = ...
|
||||
disconnect: Any = ...
|
||||
has_receivers_for: Any = ...
|
||||
receivers_for: Any = ...
|
||||
temporarily_connected_to: Any = ...
|
||||
connected_to: Any = ...
|
||||
|
||||
template_rendered: Any
|
||||
before_render_template: Any
|
||||
request_started: Any
|
||||
request_finished: Any
|
||||
request_tearing_down: Any
|
||||
got_request_exception: Any
|
||||
appcontext_tearing_down: Any
|
||||
appcontext_pushed: Any
|
||||
appcontext_popped: Any
|
||||
message_flashed: Any
|
||||
16
stubs/Flask/flask/templating.pyi
Normal file
16
stubs/Flask/flask/templating.pyi
Normal file
@@ -0,0 +1,16 @@
|
||||
from typing import Any, Iterable, Text, Union
|
||||
|
||||
from jinja2 import BaseLoader, Environment as BaseEnvironment
|
||||
|
||||
class Environment(BaseEnvironment):
|
||||
app: Any = ...
|
||||
def __init__(self, app: Any, **options: Any) -> None: ...
|
||||
|
||||
class DispatchingJinjaLoader(BaseLoader):
|
||||
app: Any = ...
|
||||
def __init__(self, app: Any) -> None: ...
|
||||
def get_source(self, environment: Any, template: Any): ...
|
||||
def list_templates(self): ...
|
||||
|
||||
def render_template(template_name_or_list: Union[Text, Iterable[Text]], **context: Any) -> Text: ...
|
||||
def render_template_string(source: Text, **context: Any) -> Text: ...
|
||||
56
stubs/Flask/flask/testing.pyi
Normal file
56
stubs/Flask/flask/testing.pyi
Normal file
@@ -0,0 +1,56 @@
|
||||
from typing import IO, Any, Iterable, Mapping, Optional, Text, TypeVar, Union
|
||||
|
||||
from click import BaseCommand
|
||||
from click.testing import CliRunner, Result
|
||||
from werkzeug.test import Client, EnvironBuilder as WerkzeugEnvironBuilder
|
||||
|
||||
# Response type for the client below.
|
||||
# By default _R is Tuple[Iterable[Any], Union[Text, int], werkzeug.datastructures.Headers], however
|
||||
# most commonly it is wrapped in a Reponse object.
|
||||
_R = TypeVar("_R")
|
||||
|
||||
class FlaskClient(Client[_R]):
|
||||
preserve_context: bool = ...
|
||||
environ_base: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def session_transaction(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def __enter__(self): ...
|
||||
def __exit__(self, exc_type: Any, exc_value: Any, tb: Any) -> None: ...
|
||||
|
||||
class FlaskCliRunner(CliRunner):
|
||||
app: Any = ...
|
||||
def __init__(self, app: Any, **kwargs: Any) -> None: ...
|
||||
def invoke(
|
||||
self,
|
||||
cli: Optional[BaseCommand] = ...,
|
||||
args: Optional[Union[str, Iterable[str]]] = ...,
|
||||
input: Optional[Union[bytes, IO[Any], Text]] = ...,
|
||||
env: Optional[Mapping[str, str]] = ...,
|
||||
catch_exceptions: bool = ...,
|
||||
color: bool = ...,
|
||||
**extra: Any,
|
||||
) -> Result: ...
|
||||
|
||||
class EnvironBuilder(WerkzeugEnvironBuilder):
|
||||
app: Any
|
||||
def __init__(
|
||||
self,
|
||||
app: Any,
|
||||
path: str = ...,
|
||||
base_url: Optional[Any] = ...,
|
||||
subdomain: Optional[Any] = ...,
|
||||
url_scheme: Optional[Any] = ...,
|
||||
*args: Any,
|
||||
**kwargs: Any,
|
||||
) -> None: ...
|
||||
def json_dumps(self, obj: Any, **kwargs: Any) -> str: ...
|
||||
|
||||
def make_test_environ_builder(
|
||||
app: Any,
|
||||
path: str = ...,
|
||||
base_url: Optional[Any] = ...,
|
||||
subdomain: Optional[Any] = ...,
|
||||
url_scheme: Optional[Any] = ...,
|
||||
*args: Any,
|
||||
**kwargs: Any,
|
||||
): ...
|
||||
17
stubs/Flask/flask/views.pyi
Normal file
17
stubs/Flask/flask/views.pyi
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import Any
|
||||
|
||||
http_method_funcs: Any
|
||||
|
||||
class View:
|
||||
methods: Any = ...
|
||||
provide_automatic_options: Any = ...
|
||||
decorators: Any = ...
|
||||
def dispatch_request(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
@classmethod
|
||||
def as_view(cls, name: Any, *class_args: Any, **class_kwargs: Any): ...
|
||||
|
||||
class MethodViewType(type):
|
||||
def __init__(self, name: Any, bases: Any, d: Any) -> None: ...
|
||||
|
||||
class MethodView(View, metaclass=MethodViewType):
|
||||
def dispatch_request(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
32
stubs/Flask/flask/wrappers.pyi
Normal file
32
stubs/Flask/flask/wrappers.pyi
Normal file
@@ -0,0 +1,32 @@
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from werkzeug.exceptions import HTTPException
|
||||
from werkzeug.routing import Rule
|
||||
from werkzeug.wrappers import Request as RequestBase, Response as ResponseBase
|
||||
|
||||
class JSONMixin:
|
||||
@property
|
||||
def is_json(self) -> bool: ...
|
||||
@property
|
||||
def json(self): ...
|
||||
def get_json(self, force: bool = ..., silent: bool = ..., cache: bool = ...): ...
|
||||
def on_json_loading_failed(self, e: Any) -> None: ...
|
||||
|
||||
class Request(RequestBase, JSONMixin):
|
||||
url_rule: Optional[Rule] = ...
|
||||
view_args: Dict[str, Any] = ...
|
||||
routing_exception: Optional[HTTPException] = ...
|
||||
# Request is making the max_content_length readonly, where it was not the
|
||||
# case in its supertype.
|
||||
# We would require something like https://github.com/python/typing/issues/241
|
||||
@property
|
||||
def max_content_length(self) -> Optional[int]: ... # type: ignore
|
||||
@property
|
||||
def endpoint(self) -> Optional[str]: ...
|
||||
@property
|
||||
def blueprint(self) -> Optional[str]: ...
|
||||
|
||||
class Response(ResponseBase, JSONMixin):
|
||||
default_mimetype: Optional[str] = ...
|
||||
@property
|
||||
def max_cookie_size(self) -> int: ...
|
||||
Reference in New Issue
Block a user