Flask-Cors: Add Flask as a dependency (#9516)

This commit is contained in:
Alex Waygood
2023-01-13 00:13:58 +00:00
committed by GitHub
parent 62170653ce
commit 8736b7a565
3 changed files with 9 additions and 8 deletions

View File

@@ -1 +1,3 @@
version = "3.0.*"
# Requires a version of flask with a `py.typed` file
requires = ["Flask>=2.0.0"]

View File

@@ -5,10 +5,10 @@ from re import Pattern
from typing import Any, TypeVar, overload
from typing_extensions import TypeAlias, TypedDict
import flask
_IterableT = TypeVar("_IterableT", bound=Iterable[Any])
_T = TypeVar("_T")
_App: TypeAlias = Any # flask is not part of typeshed
_Response: TypeAlias = Any # flask is not part of typeshed
_MultiDict: TypeAlias = Any # werkzeug is not part of typeshed
class _Options(TypedDict, total=False):
@@ -45,13 +45,13 @@ def get_regexp_pattern(regexp: str | Pattern[str]) -> str: ...
def get_cors_origins(options: _Options, request_origin: str | None) -> list[str] | None: ...
def get_allow_headers(options: _Options, acl_request_headers: str | None) -> str | None: ...
def get_cors_headers(options: _Options, request_headers: dict[str, Any], request_method: str) -> _MultiDict: ...
def set_cors_headers(resp: _Response, options: _Options) -> _Response: ...
def set_cors_headers(resp: flask.Response, options: _Options) -> flask.Response: ...
def probably_regex(maybe_regex: str | Pattern[str]) -> bool: ...
def re_fix(reg: str) -> str: ...
def try_match_any(inst: str, patterns: Iterable[str | Pattern[str]]) -> bool: ...
def try_match(request_origin: str, maybe_regex: str | Pattern[str]) -> bool: ...
def get_cors_options(appInstance: _App | None, *dicts: _Options) -> _Options: ...
def get_app_kwarg_dict(appInstance: _App | None = ...) -> _Options: ...
def get_cors_options(appInstance: flask.Flask | None, *dicts: _Options) -> _Options: ...
def get_app_kwarg_dict(appInstance: flask.Flask | None = ...) -> _Options: ...
def flexible_str(obj: object) -> str | None: ...
def serialize_option(options_dict: _Options, key: str, upper: bool = ...) -> None: ...
@overload

View File

@@ -2,9 +2,8 @@ from collections.abc import Callable, Iterable
from datetime import timedelta
from logging import Logger
from typing import Any
from typing_extensions import TypeAlias
_App: TypeAlias = Any # flask is not part of typeshed
import flask
LOG: Logger
@@ -26,7 +25,7 @@ class CORS:
) -> None: ...
def init_app(
self,
app: _App,
app: flask.Flask,
*,
resources: dict[str, dict[str, Any]] | list[str] | str = ...,
origins: str | list[str] = ...,