@@ -1185,31 +1185,23 @@ class TypeType(Type):
1185
1185
1186
1186
# This class must be created using make method which may return either TypeType or UnionType.
1187
1187
# This is to ensure Type[Union[A, B]] is always represented as Union[Type[A], Type[B]].
1188
- def __init__ (self , item : Type , * , line : int = - 1 , column : int = - 1 ) -> None :
1189
- raise NotImplementedError
1190
-
1191
- def _init (self , item : Type , * , line : int = - 1 , column : int = - 1 ) -> None :
1188
+ def __init__ (self , item : Union [Instance , AnyType , TypeVarType , TupleType , NoneTyp ,
1189
+ CallableType ], * , line : int = - 1 , column : int = - 1 ) -> None :
1192
1190
super ().__init__ (line , column )
1193
1191
if isinstance (item , CallableType ) and item .is_type_obj ():
1194
1192
self .item = item .fallback
1195
1193
else :
1196
1194
self .item = item
1197
1195
1198
- def __new__ (cls , * args , ** kwargs ): # type: ignore
1199
- instance = object .__new__ (cls )
1200
- instance ._init (* args , ** kwargs )
1201
- return instance
1202
-
1203
- def __copy__ (self ) -> 'Type' :
1204
- return TypeType .make (self .item )
1205
-
1206
1196
@staticmethod
1207
1197
def make (item : Type , * , line : int = - 1 , column : int = - 1 ) -> Type :
1208
1198
if isinstance (item , UnionType ):
1209
1199
return UnionType .make_union ([TypeType .make (union_item ) for union_item in item .items ],
1210
1200
line = line , column = column )
1201
+ elif isinstance (item , (Instance , AnyType , TypeVarType , TupleType , NoneTyp , CallableType )):
1202
+ return TypeType (item , line = line , column = column )
1211
1203
else :
1212
- return TypeType . __new__ ( TypeType , item , line = line , column = column )
1204
+ raise RuntimeError ( 'Unexpected item type' , type ( item ) )
1213
1205
1214
1206
def accept (self , visitor : 'TypeVisitor[T]' ) -> T :
1215
1207
return visitor .visit_type_type (self )
0 commit comments