@@ -288,39 +288,15 @@ def parent_of(self, node) -> bool:
288
288
"""
289
289
return any (self is parent for parent in node .node_ancestors ())
290
290
291
- @overload
292
- def statement (self , * , future : None = ...) -> nodes .Statement | nodes .Module :
293
- ...
294
-
295
- @overload
296
- def statement (self , * , future : Literal [True ]) -> nodes .Statement :
297
- ...
298
-
299
- def statement (
300
- self , * , future : Literal [None , True ] = None
301
- ) -> nodes .Statement | nodes .Module :
291
+ def statement (self , * , future : Literal [None , True ] = None ) -> nodes .Statement :
302
292
"""The first parent node, including self, marked as statement node.
303
293
304
- TODO: Deprecate the future parameter and only raise StatementMissing and return
305
- nodes.Statement
306
-
307
- :raises AttributeError: If self has no parent attribute
308
- :raises StatementMissing: If self has no parent attribute and future is True
294
+ :raises StatementMissing: If self has no parent attribute.
309
295
"""
310
296
if self .is_statement :
311
297
return cast ("nodes.Statement" , self )
312
298
if not self .parent :
313
- if future :
314
- raise StatementMissing (target = self )
315
- warnings .warn (
316
- "In astroid 3.0.0 NodeNG.statement() will return either a nodes.Statement "
317
- "or raise a StatementMissing exception. AttributeError will no longer be raised. "
318
- "This behaviour can already be triggered "
319
- "by passing 'future=True' to a statement() call." ,
320
- DeprecationWarning ,
321
- stacklevel = 2 ,
322
- )
323
- raise AttributeError (f"{ self } object has no attribute 'parent'" )
299
+ raise StatementMissing (target = self )
324
300
return self .parent .statement (future = future )
325
301
326
302
def frame (
@@ -332,20 +308,10 @@ def frame(
332
308
:class:`ClassDef` or :class:`Lambda`.
333
309
334
310
:returns: The first parent frame node.
311
+ :raises ParentMissingError: If self has no parent attribute.
335
312
"""
336
313
if self .parent is None :
337
- if future :
338
- raise ParentMissingError (target = self )
339
- warnings .warn (
340
- "In astroid 3.0.0 NodeNG.frame() will return either a Frame node, "
341
- "or raise ParentMissingError. AttributeError will no longer be raised. "
342
- "This behaviour can already be triggered "
343
- "by passing 'future=True' to a frame() call." ,
344
- DeprecationWarning ,
345
- stacklevel = 2 ,
346
- )
347
- raise AttributeError (f"{ self } object has no attribute 'parent'" )
348
-
314
+ raise ParentMissingError (target = self )
349
315
return self .parent .frame (future = future )
350
316
351
317
def scope (self ) -> nodes .LocalsDictNodeNG :
0 commit comments