pylint-bot/astroid-unofficial

.scope() is wrong for some kind of nodes

Closed this issue · 2 comments

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: PCManticore)


For instance, for a default value, astroid will return the function where it is used as its scope, but that's wrong, since the scope is actual the scope of the parent of the function.

#!python

def test(x=f): # the scope of f is test, it should be the scope of the parent of f
    pass

This is also true for the function annotation values.


Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: PCManticore):


Working on this in bookmark 2.0.

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: PCManticore):


.scope() returns the proper scope for Arguments's default values, function annotations and comprehensions. Closes issue #211.