Improve flask-cors stubs (#11708)

This commit is contained in:
Victorien
2024-04-04 12:34:44 +02:00
committed by GitHub
parent 6d8e2a80af
commit d0f3f2c06a
2 changed files with 6 additions and 4 deletions

View File

@@ -2,7 +2,7 @@ from collections.abc import Iterable
from datetime import timedelta
from logging import Logger
from re import Pattern
from typing import Any, TypedDict, TypeVar, overload
from typing import Any, Literal, TypedDict, TypeVar, overload
from typing_extensions import TypeAlias
import flask
@@ -46,7 +46,10 @@ def get_cors_origins(options: _Options, request_origin: str | None) -> list[str]
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: flask.Response, options: _Options) -> flask.Response: ...
def probably_regex(maybe_regex: str | Pattern[str]) -> bool: ...
@overload
def probably_regex(maybe_regex: Pattern[str]) -> Literal[True]: ...
@overload
def probably_regex(maybe_regex: 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: ...

View File

@@ -1,4 +1,3 @@
from _typeshed import Incomplete
from collections.abc import Callable, Iterable
from datetime import timedelta
from logging import Logger
@@ -11,7 +10,7 @@ LOG: Logger
class CORS:
def __init__(
self,
app: Incomplete | None = None,
app: flask.Flask | None = None,
*,
resources: dict[str, dict[str, Any]] | list[str] | str | None = ...,
origins: str | list[str] | None = ...,