Skip to content
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

One of the parents in chained attributes is sometimes wrong #272

Open
pylint-bot opened this issue Nov 30, 2015 · 0 comments
Open

One of the parents in chained attributes is sometimes wrong #272

pylint-bot opened this issue Nov 30, 2015 · 0 comments
Labels

Comments

@pylint-bot
Copy link
Owner

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


Here's an example where the parent of an attribute in a chained attribute is wrong, pointing to a following attribute instead.

#!python

from astroid import parse
module = parse('''
class Tags:
     def extend(self): return 42
class Removed:
     def __init__(self):
          self.tags = Tags()

removed = Removed()
removed.tags.extend()
''')
expr = module.body[-1]
callfunc = expr.value
print("callfunc", callfunc)
print("parent of callfunc", callfunc.parent)
print("func of callfunc", callfunc.func)
print("parent of func of callfunc", callfunc.func.parent)
print("expr of callfunc.func", callfunc.func.expr)
print("parent of expr of callfunc.func", callfunc.func.expr.parent)  # This should be the Name, instead it is extend

from ast import parse
module = parse('''
class Tags:
     def extend(self): return 42
class Removed:
     def __init__(self):
          self.tags = Tags()

removed = Removed()
removed.tags.extend()
''')
expr = module.body[-1]
callfunc = expr.value
print("callfunc", callfunc)
print("func of callfunc", callfunc.func.attr)
print("expr of callfunc", callfunc.func.value.attr)
print("expr of expr of callfunc", callfunc.func.value.value)

@pylint-bot pylint-bot added the bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant