Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Unreleased
- Relax typing for ``errorhandler`` to allow the user to use more
precise types and decorate the same function multiple times.
:issue:`4095, 4295, 4297`
- Fix typing for ``__exit__`` methods for better compatibility with
``ExitStack``. :issue:`4474`


Version 2.0.3
Expand Down
10 changes: 8 additions & 2 deletions src/flask/ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ def __enter__(self) -> "AppContext":
return self

def __exit__(
self, exc_type: type, exc_value: BaseException, tb: TracebackType
self,
exc_type: t.Optional[type],
exc_value: t.Optional[BaseException],
tb: t.Optional[TracebackType],
) -> None:
self.pop(exc_value)

Expand Down Expand Up @@ -491,7 +494,10 @@ def __enter__(self) -> "RequestContext":
return self

def __exit__(
self, exc_type: type, exc_value: BaseException, tb: TracebackType
self,
exc_type: t.Optional[type],
exc_value: t.Optional[BaseException],
tb: t.Optional[TracebackType],
) -> None:
# do not pop the request stack if we are in debug mode and an
# exception happened. This will allow the debugger to still
Expand Down
5 changes: 4 additions & 1 deletion src/flask/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ def __enter__(self) -> "FlaskClient":
return self

def __exit__(
self, exc_type: type, exc_value: BaseException, tb: TracebackType
self,
exc_type: t.Optional[type],
exc_value: t.Optional[BaseException],
tb: t.Optional[TracebackType],
) -> None:
self.preserve_context = False

Expand Down