|
| 1 | +from datetime import timedelta |
| 2 | +from logging import Logger |
| 3 | +from typing import Any, Iterable, Pattern, TypeVar, overload |
| 4 | +from typing_extensions import TypedDict |
| 5 | + |
| 6 | +_IterableT = TypeVar("_IterableT", bound=Iterable[Any]) |
| 7 | +_T = TypeVar("_T") |
| 8 | +_App = Any # flask is not part of typeshed |
| 9 | +_Response = Any # flask is not part of typeshed |
| 10 | +_MultiDict = Any # werkzeug is not part of typeshed |
| 11 | +_Options = TypedDict( |
| 12 | + "_Options", |
| 13 | + { |
| 14 | + "resources": dict[str, dict[str, Any]] | list[str] | str | None, |
| 15 | + "origins": str | list[str] | None, |
| 16 | + "methods": str | list[str] | None, |
| 17 | + "expose_headers": str | list[str] | None, |
| 18 | + "allow_headers": str | list[str] | None, |
| 19 | + "supports_credentials": bool | None, |
| 20 | + "max_age": timedelta | int | str | None, |
| 21 | + "send_wildcard": bool | None, |
| 22 | + "vary_header": bool | None, |
| 23 | + "automatic_options": bool | None, |
| 24 | + "intercept_exceptions": bool | None, |
| 25 | + "always_send": bool | None, |
| 26 | + }, |
| 27 | + total=False, |
| 28 | +) |
| 29 | + |
| 30 | +LOG: Logger |
| 31 | +ACL_ORIGIN: str |
| 32 | +ACL_METHODS: str |
| 33 | +ACL_ALLOW_HEADERS: str |
| 34 | +ACL_EXPOSE_HEADERS: str |
| 35 | +ACL_CREDENTIALS: str |
| 36 | +ACL_MAX_AGE: str |
| 37 | +ACL_REQUEST_METHOD: str |
| 38 | +ACL_REQUEST_HEADERS: str |
| 39 | +ALL_METHODS: list[str] |
| 40 | +CONFIG_OPTIONS: list[str] |
| 41 | +FLASK_CORS_EVALUATED: str |
| 42 | +RegexObject = Pattern[str] |
| 43 | +DEFAULT_OPTIONS: _Options |
| 44 | + |
| 45 | +def parse_resources(resources: dict[str, _Options] | Iterable[str] | str | Pattern[str]) -> list[tuple[str, _Options]]: ... |
| 46 | +def get_regexp_pattern(regexp: str | Pattern[str]) -> str: ... |
| 47 | +def get_cors_origins(options: _Options, request_origin: str | None) -> list[str] | None: ... |
| 48 | +def get_allow_headers(options: _Options, acl_request_headers: str | None) -> str | None: ... |
| 49 | +def get_cors_headers(options: _Options, request_headers: dict[str, Any], request_method: str) -> _MultiDict: ... |
| 50 | +def set_cors_headers(resp: _Response, options: _Options) -> _Response: ... |
| 51 | +def probably_regex(maybe_regex: str | Pattern[str]) -> bool: ... |
| 52 | +def re_fix(reg: str) -> str: ... |
| 53 | +def try_match_any(inst: str, patterns: Iterable[str | Pattern[str]]) -> bool: ... |
| 54 | +def try_match(request_origin: str, maybe_regex: str | Pattern[str]) -> bool: ... |
| 55 | +def get_cors_options(appInstance: _App | None, *dicts: _Options) -> _Options: ... |
| 56 | +def get_app_kwarg_dict(appInstance: _App | None = ...) -> _Options: ... |
| 57 | +def flexible_str(obj: object) -> str | None: ... |
| 58 | +def serialize_option(options_dict: _Options, key: str, upper: bool = ...) -> None: ... |
| 59 | +@overload |
| 60 | +def ensure_iterable(inst: str) -> list[str]: ... # type: ignore |
| 61 | +@overload |
| 62 | +def ensure_iterable(inst: _IterableT) -> _IterableT: ... # type: ignore |
| 63 | +@overload |
| 64 | +def ensure_iterable(inst: _T) -> list[_T]: ... |
| 65 | +def sanitize_regex_param(param: str | list[str]) -> list[str]: ... |
| 66 | +def serialize_options(opts: _Options) -> _Options: ... |
0 commit comments