@@ -241,7 +241,9 @@ def infer_name(
241
241
242
242
@decorators .raise_if_nothing_inferred
243
243
@decorators .path_wrapper
244
- def infer_call (self , context = None ):
244
+ def infer_call (
245
+ self : nodes .Call , context : InferenceContext | None = None , ** kwargs : Any
246
+ ) -> Generator [InferenceResult , None , InferenceErrorInfo ]:
245
247
"""infer a Call node by trying to guess what the function returns"""
246
248
callcontext = copy_context (context )
247
249
callcontext .boundnode = None
@@ -260,16 +262,23 @@ def infer_call(self, context=None):
260
262
yield from callee .infer_call_result (caller = self , context = callcontext )
261
263
except InferenceError :
262
264
continue
263
- return dict (node = self , context = context )
265
+ return InferenceErrorInfo (node = self , context = context )
264
266
265
267
266
268
nodes .Call ._infer = infer_call # type: ignore[assignment]
267
269
268
270
269
271
@decorators .raise_if_nothing_inferred
270
272
@decorators .path_wrapper
271
- def infer_import (self , context = None , asname = True ):
273
+ def infer_import (
274
+ self : nodes .Import ,
275
+ context : InferenceContext | None = None ,
276
+ asname : bool = True ,
277
+ ** kwargs : Any ,
278
+ ) -> Generator [nodes .Module , None , None ]:
272
279
"""infer an Import node: return the imported module/object"""
280
+ if not context :
281
+ raise InferenceError (node = self , context = context )
273
282
name = context .lookupname
274
283
if name is None :
275
284
raise InferenceError (node = self , context = context )
@@ -283,13 +292,20 @@ def infer_import(self, context=None, asname=True):
283
292
raise InferenceError (node = self , context = context ) from exc
284
293
285
294
286
- nodes .Import ._infer = infer_import
295
+ nodes .Import ._infer = infer_import # type: ignore[assignment]
287
296
288
297
289
298
@decorators .raise_if_nothing_inferred
290
299
@decorators .path_wrapper
291
- def infer_import_from (self , context = None , asname = True ):
300
+ def infer_import_from (
301
+ self : nodes .ImportFrom ,
302
+ context : InferenceContext | None = None ,
303
+ asname : bool = True ,
304
+ ** kwargs : Any ,
305
+ ) -> Generator [InferenceResult , None , None ]:
292
306
"""infer a ImportFrom node: return the imported module/object"""
307
+ if not context :
308
+ raise InferenceError (node = self , context = context )
293
309
name = context .lookupname
294
310
if name is None :
295
311
raise InferenceError (node = self , context = context )
0 commit comments