def frame( self, *, future: Literal[None, True] = None ) -> Union["nodes.FunctionDef", "nodes.Module", "nodes.ClassDef", "nodes.Lambda"]: """The first parent frame node. A frame node is a :class:`Module`, :class:`FunctionDef`, :class:`ClassDef` or :class:`Lambda`. :returns: The first parent frame node. """ if self.parent is None: if future: raise ParentMissingError(target=self) warnings.warn( "In astroid 3.0.0 NodeNG.frame() will return either a Frame node, " "or raise ParentMissingError. AttributeError will no longer be raised. " "This behaviour can already be triggered " "by passing 'future=True' to a frame() call.", DeprecationWarning, ) raise AttributeError(f"{self} object has no attribute 'parent'") return self.parent.frame(future=future)
def scope(self) -> "nodes.LocalsDictNodeNG": """The first parent node defining a new scope. These can be Module, FunctionDef, ClassDef, Lambda, or GeneratorExp nodes. :returns: The first parent scope node. """ if not self.parent: raise ParentMissingError(target=self) return self.parent.scope()