From b6ca6c99f48d83abf895fe693cf6ae7ab1450fb0 Mon Sep 17 00:00:00 2001 From: Hermes Bot Date: Tue, 26 May 2026 03:38:05 +0000 Subject: [PATCH] fix: move ssl import out of TYPE_CHECKING to fix NameError in CertParamType The ssl module was only imported under TYPE_CHECKING but was referenced in the runtime class signature of CertParamType (click.ParamType[..., ssl.SSLContext]). With --future annotations, this should work, but click.ParamType is not subscriptable and the type argument triggers eager evaluation. Fix: import ssl unconditionally and remove the subscript from ParamType since it is not a generic type. Tests: 491 passed --- src/flask/cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/flask/cli.py b/src/flask/cli.py index 5b3116ed..69a318c5 100644 --- a/src/flask/cli.py +++ b/src/flask/cli.py @@ -24,9 +24,9 @@ from .globals import current_app from .helpers import get_debug_flag from .helpers import get_load_dotenv -if t.TYPE_CHECKING: - import ssl +import ssl +if t.TYPE_CHECKING: from _typeshed.wsgi import StartResponse from _typeshed.wsgi import WSGIApplication from _typeshed.wsgi import WSGIEnvironment @@ -777,7 +777,7 @@ def show_server_banner(debug: bool, app_import_path: str | None) -> None: click.echo(f" * Debug mode: {'on' if debug else 'off'}") -class CertParamType(click.ParamType[str | os.PathLike[str] | ssl.SSLContext]): +class CertParamType(click.ParamType): # type: ignore[type-arg] """Click option type for the ``--cert`` option. Allows either an existing file, the string ``'adhoc'``, or an import for a :class:`~ssl.SSLContext` object.