From 8196dc0d129e535da69b67d0054fe725946e1f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Sat, 16 Jul 2022 16:58:27 +0200 Subject: [PATCH] Add type hints for `with_appcontext` decorator --- CHANGES.rst | 2 ++ src/flask/cli.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 078df76a..00663b09 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -95,6 +95,8 @@ Unreleased functions. :pr:`4695` - It is now possible to also call ``@with_appcontext`` decorator with parenthesis, to have additional parity with Quart. +- The ``@with_appcontext`` decorator decorator has type hints. + Version 2.1.3 ------------- diff --git a/src/flask/cli.py b/src/flask/cli.py index 94acd3b6..1d923faa 100644 --- a/src/flask/cli.py +++ b/src/flask/cli.py @@ -408,7 +408,7 @@ class ScriptInfo: pass_script_info = click.make_pass_decorator(ScriptInfo, ensure=True) -def with_appcontext(f=None): +def with_appcontext(f: t.Optional[t.Callable] = None) -> t.Callable: """Wraps a callback so that it's guaranteed to be executed with the script's application context.