From da887bf98f024076a1dead9f5d1881b6747dacb6 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Tue, 24 Feb 2026 15:58:48 +0100 Subject: [PATCH] Moved definitions of K and V outside of TYPE_CHECKING condition --- traitlets/traitlets.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/traitlets/traitlets.py b/traitlets/traitlets.py index 0f487e0e..4aa08cf3 100644 --- a/traitlets/traitlets.py +++ b/traitlets/traitlets.py @@ -505,6 +505,11 @@ def instance_init(self, obj: t.Any) -> None: K = TypeVar("K", default=str) V = TypeVar("V", default=t.Any) +else: + # This is required to avoid warnings about unresolved references when generating + # the documentation of downstream projects. + K = TypeVar("K") + V = TypeVar("V") # We use a type for the getter (G) and setter (G) because we allow