Skip to content

Commit 25884c4

Browse files
committed
fix typing that wasn't available in Python 3.6.0
1 parent 6fe7f45 commit 25884c4

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Unreleased
1212
imports in user projects. :issue:`4024`
1313
- Fix type annotation for ``g`` and inform mypy that it is a namespace
1414
object that has arbitrary attributes. :issue:`4020`
15+
- Fix some types that weren't available in Python 3.6.0. :issue:`4040`
1516

1617

1718
Version 2.0.0

src/flask/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
from .wrappers import Response
7373

7474
if t.TYPE_CHECKING:
75+
import typing_extensions as te
7576
from .blueprints import Blueprint
7677
from .testing import FlaskClient
7778
from .testing import FlaskCliRunner
@@ -1441,7 +1442,7 @@ def log_exception(
14411442
f"Exception on {request.path} [{request.method}]", exc_info=exc_info
14421443
)
14431444

1444-
def raise_routing_exception(self, request: Request) -> t.NoReturn:
1445+
def raise_routing_exception(self, request: Request) -> "te.NoReturn":
14451446
"""Exceptions that are recording during routing are reraised with
14461447
this method. During debug we are not reraising redirect requests
14471448
for non ``GET``, ``HEAD``, or ``OPTIONS`` requests and we're raising

src/flask/sessions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .json.tag import TaggedJSONSerializer
1313

1414
if t.TYPE_CHECKING:
15+
import typing_extensions as te
1516
from .app import Flask
1617
from .wrappers import Request, Response
1718

@@ -92,7 +93,7 @@ class NullSession(SecureCookieSession):
9293
but fail on setting.
9394
"""
9495

95-
def _fail(self, *args: t.Any, **kwargs: t.Any) -> t.NoReturn:
96+
def _fail(self, *args: t.Any, **kwargs: t.Any) -> "te.NoReturn":
9697
raise RuntimeError(
9798
"The session is unavailable because no secret "
9899
"key was set. Set the secret_key on the "

src/flask/wrappers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from .globals import current_app
99

1010
if t.TYPE_CHECKING:
11+
import typing_extensions as te
1112
from werkzeug.routing import Rule
1213

1314

@@ -91,7 +92,7 @@ def _load_form_data(self) -> None:
9192

9293
attach_enctype_error_multidict(self)
9394

94-
def on_json_loading_failed(self, e: Exception) -> t.NoReturn:
95+
def on_json_loading_failed(self, e: Exception) -> "te.NoReturn":
9596
if current_app and current_app.debug:
9697
raise BadRequest(f"Failed to decode JSON object: {e}")
9798

0 commit comments

Comments
 (0)