-
-
Notifications
You must be signed in to change notification settings - Fork 296
Fix frame() error on inferred node #1263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fff4db4
2cab065
8952c64
4ea13b2
42ce9f4
4629c93
9b2c483
27c1707
1b59f00
54bcb59
7bee391
9e55d84
9da479c
9fb55c5
dac07c6
3163665
08014ed
67281cb
3bee4f5
db901ce
a01e510
410445b
1d6dc24
a3b2db9
4a1a4ad
b9f0ee0
42b787e
9be8a89
08bcd08
79bb6c2
76faa99
1f1f7e7
c68db00
8bbba41
7ad182c
1fe3c11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -307,7 +307,7 @@ def statement( | |||||
return self.parent.statement(future=future) | ||||||
|
||||||
def frame( | ||||||
self, | ||||||
self, *, future: Literal[None, True] = None | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not
Suggested change
? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea behind it was to only allow two specific call options:
It doesn't really make sense to add -- @overload
def frame(self) -> Union[<all types>]:
...
@overload
def frame(self, *, future: Literal[True]) -> Union[<all types>]:
... This needs to be added to all frame definitions as overloads aren't inherited. The overloads for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably also need a # pylint: disable-next=arguments-differ
# https://github.com/PyCQA/pylint/issues/5264 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For reference, the PR to fix the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out the overload idea doesn't actually work as I though. Sorry for the confusion. The default with ...
return self.parent.frame(future=future) I've already opened another PR to fix the |
||||||
) -> Union["nodes.FunctionDef", "nodes.Module", "nodes.ClassDef", "nodes.Lambda"]: | ||||||
"""The first parent frame node. | ||||||
|
||||||
|
@@ -316,7 +316,19 @@ def frame( | |||||
|
||||||
:returns: The first parent frame node. | ||||||
""" | ||||||
return self.parent.frame() | ||||||
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. | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.