@@ -92,9 +92,15 @@ def _make_wrapper(cls, hint: object, source: "Any | None") -> "TypeHint":
92
92
return TypeVarTypeHint (hint , source )
93
93
elif origin == tuple :
94
94
return TupleTypeHint (hint , source )
95
- elif origin is None and getattr (hint , "__name__" , None ) == "TypeAlias" :
95
+
96
+ elif origin is None and type (hint ).__name__ == "_TypeAliasBase" : # Python <3.10
97
+ return TypeAliasTypeHint (hint , source )
98
+ elif origin is None and getattr (hint , "__name__" , None ) == "TypeAlias" : # Python >=3.10
96
99
return TypeAliasTypeHint (hint , source )
97
- elif origin is ClassVar or hint is ClassVar :
100
+
101
+ elif origin is None and type (hint ).__name__ == "_ClassVar" : # Python <3.10
102
+ return ClassVarTypeHint (hint , source )
103
+ elif origin is ClassVar or hint is ClassVar : # Python >=3.10
98
104
return ClassVarTypeHint (hint , source )
99
105
100
106
return ClassTypeHint (hint , source )
@@ -523,4 +529,10 @@ class TypeAliasTypeHint(TypeHint):
523
529
524
530
525
531
class ClassVarTypeHint (TypeHint ):
526
- pass
532
+ def __init__ (self , hint : object , source : "Any | None" = None ) -> None :
533
+ super ().__init__ (hint , source )
534
+ if hasattr (self .hint , "__type__" ): # Python <3.10? (Maybe lower)
535
+ if self .hint .__type__ is not None : # type: ignore[attr-defined]
536
+ self ._args = (self .hint .__type__ ,) # type: ignore[attr-defined]
537
+ else :
538
+ self ._args = ()
0 commit comments