Big diff: Use new "|" union syntax (#5872)

This commit is contained in:
Akuli
2021-08-08 12:05:21 +03:00
committed by GitHub
parent b9adb7a874
commit ee487304d7
578 changed files with 8080 additions and 8966 deletions

View File

@@ -48,7 +48,7 @@ class Flask(_PackageBoundObject):
app_ctx_globals_class: type = ...
config_class: Type[Config] = ...
testing: Any = ...
secret_key: Union[Text, bytes, None] = ...
secret_key: Text | bytes | None = ...
session_cookie_name: Any = ...
permanent_session_lifetime: timedelta = ...
send_file_max_age_default: timedelta = ...
@@ -63,19 +63,19 @@ class Flask(_PackageBoundObject):
session_interface: Any = ...
import_name: str = ...
template_folder: str = ...
root_path: Union[str, Text] = ...
root_path: str | Text = ...
static_url_path: Any = ...
static_folder: Optional[str] = ...
instance_path: Union[str, Text] = ...
static_folder: str | None = ...
instance_path: 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_request_funcs: Dict[str | None, 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]] = ...
after_request_funcs: Dict[str | None, List[Callable[[Response], Response]]] = ...
teardown_request_funcs: Dict[str | None, List[Callable[[Exception | None], Any]]] = ...
teardown_appcontext_funcs: List[Callable[[Exception | None], Any]] = ...
url_value_preprocessors: Any = ...
url_default_functions: Any = ...
template_context_processors: Any = ...
@@ -88,15 +88,15 @@ class Flask(_PackageBoundObject):
def __init__(
self,
import_name: str,
static_url_path: Optional[str] = ...,
static_folder: Optional[str] = ...,
static_host: Optional[str] = ...,
static_url_path: str | None = ...,
static_folder: str | None = ...,
static_host: str | None = ...,
host_matching: bool = ...,
subdomain_matching: bool = ...,
template_folder: str = ...,
instance_path: Optional[str] = ...,
instance_path: str | None = ...,
instance_relative_config: bool = ...,
root_path: Optional[str] = ...,
root_path: str | None = ...,
) -> None: ...
@property
def name(self) -> str: ...
@@ -112,20 +112,20 @@ class Flask(_PackageBoundObject):
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 = ...): ...
def open_instance_resource(self, resource: 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] = ...
env: str | None = ...
debug: bool = ...
def run(
self,
host: Optional[str] = ...,
port: Optional[Union[int, str]] = ...,
debug: Optional[bool] = ...,
host: str | None = ...,
port: int | str | None = ...,
debug: bool | None = ...,
load_dotenv: bool = ...,
**options: Any,
) -> None: ...
@@ -139,28 +139,26 @@ class Flask(_PackageBoundObject):
def add_url_rule(
self,
rule: str,
endpoint: Optional[str] = ...,
endpoint: str | None = ...,
view_func: _ViewFunc = ...,
provide_automatic_options: Optional[bool] = ...,
provide_automatic_options: bool | None = ...,
**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 errorhandler(self, code_or_exception: int | Type[Exception]) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
def register_error_handler(self, code_or_exception: int | Type[Exception], f: Callable[..., Any]) -> None: ...
def template_filter(self, name: Any | None = ...): ...
def add_template_filter(self, f: Any, name: Any | None = ...) -> None: ...
def template_test(self, name: Any | None = ...): ...
def add_template_test(self, f: Any, name: Any | None = ...) -> None: ...
def template_global(self, name: Any | None = ...): ...
def add_template_global(self, f: Any, name: Any | None = ...) -> 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 teardown_request(self, f: Callable[[Exception | None], _T]) -> Callable[[Exception | None], _T]: ...
def teardown_appcontext(self, f: Callable[[Exception | None], _T]) -> Callable[[Exception | None], _T]: ...
def context_processor(self, f: Any): ...
def shell_context_processor(self, f: Any): ...
def url_value_preprocessor(self, f: Any): ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Optional, Type, TypeVar, Union
from typing import Any, Callable, Type, TypeVar
from .app import _ViewFunc
from .helpers import _PackageBoundObject
@@ -17,49 +17,49 @@ 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: _ViewFunc = ..., **options: Any) -> None: ...
def add_url_rule(self, rule: str, endpoint: str | None = ..., 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] = ...
template_folder: str | None = ...
root_path: str = ...
name: str = ...
url_prefix: Optional[str] = ...
subdomain: Optional[str] = ...
static_folder: Optional[str] = ...
static_url_path: Optional[str] = ...
url_prefix: str | None = ...
subdomain: str | None = ...
static_folder: str | None = ...
static_url_path: str | None = ...
deferred_functions: Any = ...
url_values_defaults: Any = ...
cli_group: Union[Optional[str], _Sentinel] = ...
cli_group: str | None | _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] = ...,
static_folder: str | None = ...,
static_url_path: str | None = ...,
template_folder: str | None = ...,
url_prefix: str | None = ...,
subdomain: str | None = ...,
url_defaults: Any | None = ...,
root_path: str | None = ...,
cli_group: str | None | _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 add_url_rule(self, rule: str, endpoint: str | None = ..., 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 app_template_filter(self, name: Any | None = ...): ...
def add_app_template_filter(self, f: Any, name: Any | None = ...) -> None: ...
def app_template_test(self, name: Any | None = ...): ...
def add_app_template_test(self, f: Any, name: Any | None = ...) -> None: ...
def app_template_global(self, name: Any | None = ...): ...
def add_app_template_global(self, f: Any, name: Any | None = ...) -> None: ...
def before_request(self, f: Any): ...
def before_app_request(self, f: Any): ...
def before_app_first_request(self, f: Any): ...
@@ -74,7 +74,5 @@ class Blueprint(_PackageBoundObject):
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: ...
def errorhandler(self, code_or_exception: int | Type[Exception]) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
def register_error_handler(self, code_or_exception: int | Type[Exception], f: Callable[..., Any]) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any
import click
@@ -22,7 +22,7 @@ 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 __init__(self, app_import_path: Any | None = ..., create_app: Any | None = ...) -> None: ...
def load_app(self): ...
pass_script_info: Any
@@ -39,7 +39,7 @@ class FlaskGroup(AppGroup):
def __init__(
self,
add_default_commands: bool = ...,
create_app: Optional[Any] = ...,
create_app: Any | None = ...,
add_version_option: bool = ...,
load_dotenv: bool = ...,
**extra: Any,
@@ -48,7 +48,7 @@ class FlaskGroup(AppGroup):
def list_commands(self, ctx: Any): ...
def main(self, *args: Any, **kwargs: Any): ...
def load_dotenv(path: Optional[Any] = ...): ...
def load_dotenv(path: Any | None = ...): ...
def show_server_banner(env: Any, debug: Any, app_import_path: Any, eager_loading: Any): ...
class CertParamType(click.ParamType):

View File

@@ -1,15 +1,15 @@
from typing import Any, Dict, Optional
from typing import Any, Dict
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 __init__(self, name: Any, get_converter: Any | None = ...) -> None: ...
def __get__(self, obj: Any, type: Any | None = ...): ...
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 __init__(self, root_path: Any, defaults: Any | None = ...) -> 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: ...

View File

@@ -1,9 +1,9 @@
from typing import Any, Optional
from typing import Any
class _AppCtxGlobals:
def get(self, name: Any, default: Optional[Any] = ...): ...
def get(self, name: Any, default: Any | None = ...): ...
def pop(self, name: Any, default: Any = ...): ...
def setdefault(self, name: Any, default: Optional[Any] = ...): ...
def setdefault(self, name: Any, default: Any | None = ...): ...
def __contains__(self, item: Any): ...
def __iter__(self): ...
@@ -29,7 +29,7 @@ class RequestContext:
flashes: Any = ...
session: Any = ...
preserved: bool = ...
def __init__(self, app: Any, environ: Any, request: Optional[Any] = ...) -> None: ...
def __init__(self, app: Any, environ: Any, request: Any | None = ...) -> None: ...
g: Any = ...
def copy(self): ...
def match_request(self) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any
from .cli import AppGroup
from .wrappers import Response
@@ -14,13 +14,13 @@ 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] = ...,
mimetype: Any | None = ...,
as_attachment: bool = ...,
attachment_filename: Optional[Any] = ...,
attachment_filename: Any | None = ...,
add_etags: bool = ...,
cache_timeout: Optional[Any] = ...,
cache_timeout: Any | None = ...,
conditional: bool = ...,
last_modified: Optional[Any] = ...,
last_modified: Any | None = ...,
) -> Response: ...
def safe_join(directory: Any, *pathnames: Any): ...
def send_from_directory(directory: Any, filename: Any, **options: Any) -> Response: ...
@@ -33,15 +33,15 @@ class locked_cached_property:
__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] = ...): ...
def __init__(self, func: Any, name: Any | None = ..., doc: Any | None = ...) -> None: ...
def __get__(self, obj: Any, type: Any | None = ...): ...
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: ...
def __init__(self, import_name: Any, template_folder: Any | None = ..., root_path: Any | None = ...) -> None: ...
static_folder: Any = ...
static_url_path: Any = ...
@property

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any
class JSONTag:
key: Any = ...
@@ -60,7 +60,7 @@ class TaggedJSONSerializer:
tags: Any = ...
order: Any = ...
def __init__(self) -> None: ...
def register(self, tag_class: Any, force: bool = ..., index: Optional[Any] = ...) -> None: ...
def register(self, tag_class: Any, force: bool = ..., index: Any | None = ...) -> None: ...
def tag(self, value: Any): ...
def untag(self, value: Any): ...
def dumps(self, value: Any): ...

View File

@@ -1,5 +1,5 @@
from abc import ABCMeta
from typing import Any, MutableMapping, Optional
from typing import Any, MutableMapping
from werkzeug.datastructures import CallbackDict
@@ -15,10 +15,10 @@ class SessionMixin(MutableMapping[str, Any], metaclass=ABCMeta):
class SecureCookieSession(CallbackDict[str, Any], SessionMixin):
modified: bool = ...
accessed: bool = ...
def __init__(self, initial: Optional[Any] = ...) -> None: ...
def __init__(self, initial: Any | None = ...) -> None: ...
def __getitem__(self, key: Any): ...
def get(self, key: Any, default: Optional[Any] = ...): ...
def setdefault(self, key: Any, default: Optional[Any] = ...): ...
def get(self, key: Any, default: Any | None = ...): ...
def setdefault(self, key: Any, default: Any | None = ...): ...
class NullSession(SecureCookieSession):
__setitem__: Any = ...

View File

@@ -1,14 +1,14 @@
from typing import Any, Optional
from typing import Any
signals_available: bool
class Namespace:
def signal(self, name: Any, doc: Optional[Any] = ...): ...
def signal(self, name: Any, doc: Any | None = ...): ...
class _FakeSignal:
name: Any = ...
__doc__: Any = ...
def __init__(self, name: Any, doc: Optional[Any] = ...) -> None: ...
def __init__(self, name: Any, doc: Any | None = ...) -> None: ...
send: Any = ...
connect: Any = ...
disconnect: Any = ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Iterable, Text, Union
from typing import Any, Iterable, Text
from jinja2 import BaseLoader, Environment as BaseEnvironment
@@ -12,5 +12,5 @@ class DispatchingJinjaLoader(BaseLoader):
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(template_name_or_list: Text | Iterable[Text], **context: Any) -> Text: ...
def render_template_string(source: Text, **context: Any) -> Text: ...

View File

@@ -1,11 +1,11 @@
from typing import IO, Any, Iterable, Mapping, Optional, Text, TypeVar, Union
from typing import IO, Any, Iterable, Mapping, Text, TypeVar
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
# By default _R is Tuple[Iterable[Any], Text | int, werkzeug.datastructures.Headers], however
# most commonly it is wrapped in a Reponse object.
_R = TypeVar("_R")
@@ -22,10 +22,10 @@ class FlaskCliRunner(CliRunner):
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]] = ...,
cli: BaseCommand | None = ...,
args: str | Iterable[str] | None = ...,
input: bytes | IO[Any] | Text | None = ...,
env: Mapping[str, str] | None = ...,
catch_exceptions: bool = ...,
color: bool = ...,
**extra: Any,
@@ -37,9 +37,9 @@ class EnvironBuilder(WerkzeugEnvironBuilder):
self,
app: Any,
path: str = ...,
base_url: Optional[Any] = ...,
subdomain: Optional[Any] = ...,
url_scheme: Optional[Any] = ...,
base_url: Any | None = ...,
subdomain: Any | None = ...,
url_scheme: Any | None = ...,
*args: Any,
**kwargs: Any,
) -> None: ...
@@ -48,9 +48,9 @@ class EnvironBuilder(WerkzeugEnvironBuilder):
def make_test_environ_builder(
app: Any,
path: str = ...,
base_url: Optional[Any] = ...,
subdomain: Optional[Any] = ...,
url_scheme: Optional[Any] = ...,
base_url: Any | None = ...,
subdomain: Any | None = ...,
url_scheme: Any | None = ...,
*args: Any,
**kwargs: Any,
): ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional
from typing import Any, Dict
from werkzeug.exceptions import HTTPException
from werkzeug.routing import Rule
@@ -13,20 +13,20 @@ class JSONMixin:
def on_json_loading_failed(self, e: Any) -> None: ...
class Request(RequestBase, JSONMixin):
url_rule: Optional[Rule] = ...
url_rule: Rule | None = ...
view_args: Dict[str, Any] = ...
routing_exception: Optional[HTTPException] = ...
routing_exception: HTTPException | None = ...
# 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
def max_content_length(self) -> int | None: ... # type: ignore
@property
def endpoint(self) -> Optional[str]: ...
def endpoint(self) -> str | None: ...
@property
def blueprint(self) -> Optional[str]: ...
def blueprint(self) -> str | None: ...
class Response(ResponseBase, JSONMixin):
default_mimetype: Optional[str] = ...
default_mimetype: str | None = ...
@property
def max_cookie_size(self) -> int: ...