-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add stubs for flask-cors #6939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add stubs for flask-cors #6939
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3bf13ce
Add stubs for flask-cors
kasium d85996c
Add test allow list
kasium df6297e
Update stubs/Flask-Cors/flask_cors/core.pyi
kasium aedc083
Update stubs/Flask-Cors/flask_cors/core.pyi
kasium d08aa2b
Update stubs/Flask-Cors/flask_cors/decorator.pyi
kasium 8c6a64b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4843aa2
Work
kasium 3b107c6
Merge branch 'flask-cors' of github.com:kasium/typeshed into flask-cors
kasium 46d0f22
Fix
kasium 7669d05
Work
kasium 6d9546d
overload
kasium f9f5bc2
ignores
kasium 78c5ada
Update stubs/Flask-Cors/flask_cors/decorator.pyi
kasium 91a302d
Work
kasium 1ddd9a9
Fix
kasium 411868b
Add ignore
kasium File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Caused by https://github.com/python/mypy/pull/12040 | ||
flask_cors.core.DEFAULT_OPTIONS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version = "3.0.*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from logging import Logger | ||
|
||
from .decorator import cross_origin as cross_origin | ||
from .extension import CORS as CORS | ||
from .version import __version__ as __version__ | ||
|
||
rootlogger: Logger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from datetime import timedelta | ||
from logging import Logger | ||
from typing import Any, Iterable, Pattern, TypeVar, overload | ||
from typing_extensions import TypedDict | ||
|
||
_IterableT = TypeVar("_IterableT", bound=Iterable[Any]) | ||
_T = TypeVar("_T") | ||
_App = Any # flask is not part of typeshed | ||
_Response = Any # flask is not part of typeshed | ||
_MultiDict = Any # werkzeug is not part of typeshed | ||
_Options = TypedDict( | ||
"_Options", | ||
{ | ||
"resources": dict[str, dict[str, Any]] | list[str] | str | None, | ||
"origins": str | list[str] | None, | ||
"methods": str | list[str] | None, | ||
"expose_headers": str | list[str] | None, | ||
"allow_headers": str | list[str] | None, | ||
"supports_credentials": bool | None, | ||
"max_age": timedelta | int | str | None, | ||
"send_wildcard": bool | None, | ||
"vary_header": bool | None, | ||
"automatic_options": bool | None, | ||
"intercept_exceptions": bool | None, | ||
"always_send": bool | None, | ||
}, | ||
total=False, | ||
) | ||
|
||
LOG: Logger | ||
ACL_ORIGIN: str | ||
ACL_METHODS: str | ||
ACL_ALLOW_HEADERS: str | ||
ACL_EXPOSE_HEADERS: str | ||
ACL_CREDENTIALS: str | ||
ACL_MAX_AGE: str | ||
ACL_REQUEST_METHOD: str | ||
ACL_REQUEST_HEADERS: str | ||
ALL_METHODS: list[str] | ||
CONFIG_OPTIONS: list[str] | ||
FLASK_CORS_EVALUATED: str | ||
RegexObject = Pattern[str] | ||
DEFAULT_OPTIONS: _Options | ||
|
||
def parse_resources(resources: dict[str, _Options] | Iterable[str] | str | Pattern[str]) -> list[tuple[str, _Options]]: ... | ||
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 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 flexible_str(obj: object) -> str | None: ... | ||
def serialize_option(options_dict: _Options, key: str, upper: bool = ...) -> None: ... | ||
@overload | ||
def ensure_iterable(inst: str) -> list[str]: ... # type: ignore | ||
@overload | ||
def ensure_iterable(inst: _IterableT) -> _IterableT: ... # type: ignore | ||
@overload | ||
def ensure_iterable(inst: _T) -> list[_T]: ... | ||
def sanitize_regex_param(param: str | list[str]) -> list[str]: ... | ||
def serialize_options(opts: _Options) -> _Options: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from datetime import timedelta | ||
from logging import Logger | ||
from typing import Any, Callable | ||
from typing_extensions import ParamSpec | ||
|
||
_P = ParamSpec("_P") | ||
|
||
LOG: Logger | ||
|
||
def cross_origin( | ||
kasium marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*args: Any, | ||
origins: str | list[str] | None, | ||
methods: str | list[str] | None, | ||
expose_headers: str | list[str] | None, | ||
allow_headers: str | list[str] | None, | ||
supports_credentials: bool | None, | ||
max_age: timedelta | int | str | None, | ||
send_wildcard: bool | None, | ||
vary_header: bool | None, | ||
automatic_options: bool | None, | ||
) -> Callable[[Callable[_P, Any]], Callable[_P, Any]]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from datetime import timedelta | ||
from logging import Logger | ||
from typing import Any, Callable, Iterable | ||
|
||
_App = Any # flask is not part of typeshed | ||
|
||
LOG: Logger | ||
|
||
class CORS: | ||
def __init__( | ||
self, | ||
app: Any | None = ..., | ||
*, | ||
resources: dict[str, dict[str, Any]] | list[str] | str | None = ..., | ||
origins: str | list[str] | None = ..., | ||
methods: str | list[str] | None = ..., | ||
expose_headers: str | list[str] | None = ..., | ||
allow_headers: str | list[str] | None = ..., | ||
supports_credentials: bool | None = ..., | ||
max_age: timedelta | int | str | None = ..., | ||
send_wildcard: bool | None = ..., | ||
vary_header: bool | None = ..., | ||
**kwargs: Any, | ||
) -> None: ... | ||
def init_app( | ||
self, | ||
app: _App, | ||
*, | ||
resources: dict[str, dict[str, Any]] | list[str] | str = ..., | ||
origins: str | list[str] = ..., | ||
methods: str | list[str] = ..., | ||
expose_headers: str | list[str] = ..., | ||
allow_headers: str | list[str] = ..., | ||
supports_credentials: bool = ..., | ||
max_age: timedelta | int | str | None = ..., | ||
send_wildcard: bool = ..., | ||
vary_header: bool = ..., | ||
**kwargs: Any, | ||
) -> None: ... | ||
|
||
def make_after_request_function(resources: Iterable[tuple[str, dict[str, Any]]]) -> Callable[..., Any]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__: str |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use class syntax for TypedDict:
class _Options(TypedDict, total=False):
.