Skip to content

Commit 756bc76

Browse files
committed
Moved definitions of K and V outside of TYPE_CHECKING condition
1 parent 1ae9579 commit 756bc76

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

traitlets/traitlets.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,17 +495,15 @@ def instance_init(self, obj: t.Any) -> None:
495495
G = TypeVar("G")
496496
S = TypeVar("S")
497497
T = TypeVar("T")
498-
498+
K = TypeVar("K", default=str)
499+
V = TypeVar("V", default=t.Any)
499500

500501
# Self from typing extension doesn't work well with mypy https://github.com/python/mypy/pull/14041
501502
# see https://peps.python.org/pep-0673/#use-in-generic-classes
502503
# Self = t.TypeVar("Self", bound="TraitType[Any, Any]")
503504
if t.TYPE_CHECKING:
504505
from typing_extensions import Literal, Self
505506

506-
K = TypeVar("K", default=str)
507-
V = TypeVar("V", default=t.Any)
508-
509507

510508
# We use a type for the getter (G) and setter (G) because we allow
511509
# for traits to cast (for instance CInt will use G=int, S=t.Any)

0 commit comments

Comments
 (0)