Skip to content

AI junk#6037

Closed
Architect8989 wants to merge 1 commit into
pallets:mainfrom
Architect8989:fix/cli-ssl-import
Closed

AI junk#6037
Architect8989 wants to merge 1 commit into
pallets:mainfrom
Architect8989:fix/cli-ssl-import

Conversation

@Architect8989

Copy link
Copy Markdown

Fix: ssl import moved out of TYPE_CHECKING block

Problem

from flask.cli import CertParamType raises NameError: name 'ssl' is not defined because ssl is only imported under TYPE_CHECKING, but referenced in the class signature:

class CertParamType(click.ParamType[str | os.PathLike[str] | ssl.SSLContext]):

Root Cause

Even with from __future__ import annotations, click.ParamType is not subscriptable. The subscript causes eager evaluation of the type arguments at class definition time.

Fix

  1. Move import ssl out of the if t.TYPE_CHECKING: block to the top-level imports
  2. Remove subscript from click.ParamType[...] since ParamType is not generic

Verification

  • All 491 tests pass
  • from flask import Flask imports without error

…amType

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
@davidism davidism closed this May 26, 2026
@davidism davidism changed the title fix: move ssl import out of TYPE_CHECKING to fix NameError in CertParamType AI junk May 26, 2026
@jwag956

jwag956 commented May 28, 2026

Copy link
Copy Markdown

Hi David... I am actually getting the exact same error running Flask-Security tests against latest main Flask...
Using python 3.13...

@davidism

Copy link
Copy Markdown
Member

Ok, please report an issue and if you want open a human written pr.

@pallets pallets locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants