@@ -829,8 +829,11 @@ pub enum KnownClass {
829
829
StdlibAlias ,
830
830
SpecialForm ,
831
831
TypeVar ,
832
+ ParamSpec ,
833
+ TypeVarTuple ,
832
834
TypeAliasType ,
833
835
NoDefaultType ,
836
+ NewType ,
834
837
// TODO: This can probably be removed when we have support for protocols
835
838
SupportsIndex ,
836
839
// Collections
@@ -873,6 +876,8 @@ impl<'db> KnownClass {
873
876
| Self :: VersionInfo
874
877
| Self :: TypeAliasType
875
878
| Self :: TypeVar
879
+ | Self :: ParamSpec
880
+ | Self :: TypeVarTuple
876
881
| Self :: WrapperDescriptorType
877
882
| Self :: MethodWrapperType => Truthiness :: AlwaysTrue ,
878
883
@@ -886,6 +891,7 @@ impl<'db> KnownClass {
886
891
| Self :: Str
887
892
| Self :: List
888
893
| Self :: GenericAlias
894
+ | Self :: NewType
889
895
| Self :: StdlibAlias
890
896
| Self :: SupportsIndex
891
897
| Self :: Set
@@ -939,8 +945,11 @@ impl<'db> KnownClass {
939
945
Self :: NoneType => "NoneType" ,
940
946
Self :: SpecialForm => "_SpecialForm" ,
941
947
Self :: TypeVar => "TypeVar" ,
948
+ Self :: ParamSpec => "ParamSpec" ,
949
+ Self :: TypeVarTuple => "TypeVarTuple" ,
942
950
Self :: TypeAliasType => "TypeAliasType" ,
943
951
Self :: NoDefaultType => "_NoDefaultType" ,
952
+ Self :: NewType => "NewType" ,
944
953
Self :: SupportsIndex => "SupportsIndex" ,
945
954
Self :: ChainMap => "ChainMap" ,
946
955
Self :: Counter => "Counter" ,
@@ -1109,7 +1118,9 @@ impl<'db> KnownClass {
1109
1118
Self :: SpecialForm | Self :: TypeVar | Self :: StdlibAlias | Self :: SupportsIndex => {
1110
1119
KnownModule :: Typing
1111
1120
}
1112
- Self :: TypeAliasType => KnownModule :: TypingExtensions ,
1121
+ Self :: TypeAliasType | Self :: TypeVarTuple | Self :: ParamSpec | Self :: NewType => {
1122
+ KnownModule :: TypingExtensions
1123
+ }
1113
1124
Self :: NoDefaultType => {
1114
1125
let python_version = Program :: get ( db) . python_version ( db) ;
1115
1126
@@ -1142,46 +1153,49 @@ impl<'db> KnownClass {
1142
1153
/// Return true if all instances of this `KnownClass` compare equal.
1143
1154
pub ( super ) const fn is_single_valued ( self ) -> bool {
1144
1155
match self {
1145
- KnownClass :: NoneType
1146
- | KnownClass :: NoDefaultType
1147
- | KnownClass :: VersionInfo
1148
- | KnownClass :: EllipsisType
1149
- | KnownClass :: TypeAliasType => true ,
1150
-
1151
- KnownClass :: Bool
1152
- | KnownClass :: Object
1153
- | KnownClass :: Bytes
1154
- | KnownClass :: Type
1155
- | KnownClass :: Int
1156
- | KnownClass :: Float
1157
- | KnownClass :: Complex
1158
- | KnownClass :: Str
1159
- | KnownClass :: List
1160
- | KnownClass :: Tuple
1161
- | KnownClass :: Set
1162
- | KnownClass :: FrozenSet
1163
- | KnownClass :: Dict
1164
- | KnownClass :: Slice
1165
- | KnownClass :: Range
1166
- | KnownClass :: Property
1167
- | KnownClass :: BaseException
1168
- | KnownClass :: BaseExceptionGroup
1169
- | KnownClass :: Classmethod
1170
- | KnownClass :: GenericAlias
1171
- | KnownClass :: ModuleType
1172
- | KnownClass :: FunctionType
1173
- | KnownClass :: MethodType
1174
- | KnownClass :: MethodWrapperType
1175
- | KnownClass :: WrapperDescriptorType
1176
- | KnownClass :: SpecialForm
1177
- | KnownClass :: ChainMap
1178
- | KnownClass :: Counter
1179
- | KnownClass :: DefaultDict
1180
- | KnownClass :: Deque
1181
- | KnownClass :: OrderedDict
1182
- | KnownClass :: SupportsIndex
1183
- | KnownClass :: StdlibAlias
1184
- | KnownClass :: TypeVar => false ,
1156
+ Self :: NoneType
1157
+ | Self :: NoDefaultType
1158
+ | Self :: VersionInfo
1159
+ | Self :: EllipsisType
1160
+ | Self :: TypeAliasType => true ,
1161
+
1162
+ Self :: Bool
1163
+ | Self :: Object
1164
+ | Self :: Bytes
1165
+ | Self :: Type
1166
+ | Self :: Int
1167
+ | Self :: Float
1168
+ | Self :: Complex
1169
+ | Self :: Str
1170
+ | Self :: List
1171
+ | Self :: Tuple
1172
+ | Self :: Set
1173
+ | Self :: FrozenSet
1174
+ | Self :: Dict
1175
+ | Self :: Slice
1176
+ | Self :: Range
1177
+ | Self :: Property
1178
+ | Self :: BaseException
1179
+ | Self :: BaseExceptionGroup
1180
+ | Self :: Classmethod
1181
+ | Self :: GenericAlias
1182
+ | Self :: ModuleType
1183
+ | Self :: FunctionType
1184
+ | Self :: MethodType
1185
+ | Self :: MethodWrapperType
1186
+ | Self :: WrapperDescriptorType
1187
+ | Self :: SpecialForm
1188
+ | Self :: ChainMap
1189
+ | Self :: Counter
1190
+ | Self :: DefaultDict
1191
+ | Self :: Deque
1192
+ | Self :: OrderedDict
1193
+ | Self :: SupportsIndex
1194
+ | Self :: StdlibAlias
1195
+ | Self :: TypeVar
1196
+ | Self :: ParamSpec
1197
+ | Self :: TypeVarTuple
1198
+ | Self :: NewType => false ,
1185
1199
}
1186
1200
}
1187
1201
@@ -1230,7 +1244,10 @@ impl<'db> KnownClass {
1230
1244
| Self :: BaseException
1231
1245
| Self :: BaseExceptionGroup
1232
1246
| Self :: Classmethod
1233
- | Self :: TypeVar => false ,
1247
+ | Self :: TypeVar
1248
+ | Self :: ParamSpec
1249
+ | Self :: TypeVarTuple
1250
+ | Self :: NewType => false ,
1234
1251
}
1235
1252
}
1236
1253
@@ -1268,8 +1285,11 @@ impl<'db> KnownClass {
1268
1285
"MethodType" => Self :: MethodType ,
1269
1286
"MethodWrapperType" => Self :: MethodWrapperType ,
1270
1287
"WrapperDescriptorType" => Self :: WrapperDescriptorType ,
1288
+ "NewType" => Self :: NewType ,
1271
1289
"TypeAliasType" => Self :: TypeAliasType ,
1272
1290
"TypeVar" => Self :: TypeVar ,
1291
+ "ParamSpec" => Self :: ParamSpec ,
1292
+ "TypeVarTuple" => Self :: TypeVarTuple ,
1273
1293
"ChainMap" => Self :: ChainMap ,
1274
1294
"Counter" => Self :: Counter ,
1275
1295
"defaultdict" => Self :: DefaultDict ,
@@ -1331,9 +1351,14 @@ impl<'db> KnownClass {
1331
1351
| Self :: MethodWrapperType
1332
1352
| Self :: WrapperDescriptorType => module == self . canonical_module ( db) ,
1333
1353
Self :: NoneType => matches ! ( module, KnownModule :: Typeshed | KnownModule :: Types ) ,
1334
- Self :: SpecialForm | Self :: TypeVar | Self :: TypeAliasType | Self :: NoDefaultType | Self :: SupportsIndex => {
1335
- matches ! ( module, KnownModule :: Typing | KnownModule :: TypingExtensions )
1336
- }
1354
+ Self :: SpecialForm
1355
+ | Self :: TypeVar
1356
+ | Self :: TypeAliasType
1357
+ | Self :: NoDefaultType
1358
+ | Self :: SupportsIndex
1359
+ | Self :: ParamSpec
1360
+ | Self :: TypeVarTuple
1361
+ | Self :: NewType => matches ! ( module, KnownModule :: Typing | KnownModule :: TypingExtensions ) ,
1337
1362
}
1338
1363
}
1339
1364
}
0 commit comments