Skip to content

Comments

Moved definitions of K and V outside of TYPE_CHECKING condition#935

Merged
Carreau merged 1 commit intoipython:mainfrom
JohanMabille:type_var
Feb 25, 2026
Merged

Moved definitions of K and V outside of TYPE_CHECKING condition#935
Carreau merged 1 commit intoipython:mainfrom
JohanMabille:type_var

Conversation

@JohanMabille
Copy link
Contributor

@JohanMabille JohanMabille commented Feb 24, 2026

This fixes the WARNING: Cannot resolve forward reference in type annotations of "jupyter_client.consoleapp.Dict": name 'K' is not defined [sphinx_autodoc_typehints.forward_reference that we got when generating the jupyter_client documentation (see this PR).

@JohanMabille
Copy link
Contributor Author

The failure on PyPy is fixed in #936

# This is required to avoid warnings about unresolved references when generating
# the documentation of downstream projects.
K = TypeVar("K")
V = TypeVar("V")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can just dedent the K,V definition from the if block, but it does not matter much.

@Carreau Carreau merged commit 7cac5b9 into ipython:main Feb 25, 2026
33 of 35 checks passed
@JohanMabille JohanMabille deleted the type_var branch February 25, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants