PyCQA / redbaron

Bottom-up approach to refactoring in python
http://redbaron.pycqa.org/
694 stars 74 forks source link

from_import .names() crashes when imports are in parenthesis #178

Closed obormot closed 5 years ago

obormot commented 5 years ago

Python 3.5.6 redbaron 0.8 installed from pip

>>> red = redbaron.RedBaron("from foo import (one, two)")
>>> red.find('from_import').names()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python3.5/site-packages/redbaron/nodes.py", line 604, in names
    return [x.target if x.target else x.value for x in self.targets]
  File ".../lib/python3.5/site-packages/redbaron/nodes.py", line 604, in <listcomp>
    return [x.target if x.target else x.value for x in self.targets]
  File ".../lib/python3.5/site-packages/redbaron/base_nodes.py", line 718, in __getattr__
    self.__class__.__name__, key, key))
AttributeError: LeftParenthesisNode instance has no attribute 'target' and 'target' is not a valid identifier of another node
>>>
Psycojoker commented 5 years ago

Fix in release 0.9.1 (with similar fixes), thx for reporting <3