fix typing that wasn't available in Python 3.6.0
This commit is contained in:
parent
6fe7f45725
commit
25884c433f
4 changed files with 7 additions and 3 deletions
|
|
@ -12,6 +12,7 @@ Unreleased
|
||||||
imports in user projects. :issue:`4024`
|
imports in user projects. :issue:`4024`
|
||||||
- Fix type annotation for ``g`` and inform mypy that it is a namespace
|
- Fix type annotation for ``g`` and inform mypy that it is a namespace
|
||||||
object that has arbitrary attributes. :issue:`4020`
|
object that has arbitrary attributes. :issue:`4020`
|
||||||
|
- Fix some types that weren't available in Python 3.6.0. :issue:`4040`
|
||||||
|
|
||||||
|
|
||||||
Version 2.0.0
|
Version 2.0.0
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ from .wrappers import Request
|
||||||
from .wrappers import Response
|
from .wrappers import Response
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
|
import typing_extensions as te
|
||||||
from .blueprints import Blueprint
|
from .blueprints import Blueprint
|
||||||
from .testing import FlaskClient
|
from .testing import FlaskClient
|
||||||
from .testing import FlaskCliRunner
|
from .testing import FlaskCliRunner
|
||||||
|
|
@ -1441,7 +1442,7 @@ class Flask(Scaffold):
|
||||||
f"Exception on {request.path} [{request.method}]", exc_info=exc_info
|
f"Exception on {request.path} [{request.method}]", exc_info=exc_info
|
||||||
)
|
)
|
||||||
|
|
||||||
def raise_routing_exception(self, request: Request) -> t.NoReturn:
|
def raise_routing_exception(self, request: Request) -> "te.NoReturn":
|
||||||
"""Exceptions that are recording during routing are reraised with
|
"""Exceptions that are recording during routing are reraised with
|
||||||
this method. During debug we are not reraising redirect requests
|
this method. During debug we are not reraising redirect requests
|
||||||
for non ``GET``, ``HEAD``, or ``OPTIONS`` requests and we're raising
|
for non ``GET``, ``HEAD``, or ``OPTIONS`` requests and we're raising
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ from .helpers import is_ip
|
||||||
from .json.tag import TaggedJSONSerializer
|
from .json.tag import TaggedJSONSerializer
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
|
import typing_extensions as te
|
||||||
from .app import Flask
|
from .app import Flask
|
||||||
from .wrappers import Request, Response
|
from .wrappers import Request, Response
|
||||||
|
|
||||||
|
|
@ -92,7 +93,7 @@ class NullSession(SecureCookieSession):
|
||||||
but fail on setting.
|
but fail on setting.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _fail(self, *args: t.Any, **kwargs: t.Any) -> t.NoReturn:
|
def _fail(self, *args: t.Any, **kwargs: t.Any) -> "te.NoReturn":
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"The session is unavailable because no secret "
|
"The session is unavailable because no secret "
|
||||||
"key was set. Set the secret_key on the "
|
"key was set. Set the secret_key on the "
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ from . import json
|
||||||
from .globals import current_app
|
from .globals import current_app
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
|
import typing_extensions as te
|
||||||
from werkzeug.routing import Rule
|
from werkzeug.routing import Rule
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -91,7 +92,7 @@ class Request(RequestBase):
|
||||||
|
|
||||||
attach_enctype_error_multidict(self)
|
attach_enctype_error_multidict(self)
|
||||||
|
|
||||||
def on_json_loading_failed(self, e: Exception) -> t.NoReturn:
|
def on_json_loading_failed(self, e: Exception) -> "te.NoReturn":
|
||||||
if current_app and current_app.debug:
|
if current_app and current_app.debug:
|
||||||
raise BadRequest(f"Failed to decode JSON object: {e}")
|
raise BadRequest(f"Failed to decode JSON object: {e}")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue