PyCQA / redbaron

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

Modifying formatting of lambda statement seems broken #138

Open Psycojoker opened 7 years ago

Psycojoker commented 7 years ago

This code:

RedBaron("lambda x: True")[0].second_formatting = ""

Produces this error:

In [14]: RedBaron("lambda x: True")[0].second_formatting = ""
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-14-4cf0b95078b0> in <module>()
----> 1 RedBaron("lambda x: True")[0].second_formatting = ""

/home/psycojoker/code/python/redbaron/redbaron/nodes.pyc in __setattr__(self, key, value)
    785 
    786     def __setattr__(self, key, value):
--> 787         super(LambdaNode, self).__setattr__(key, value)
    788 
    789         if key == "arguments" and not isinstance(self.arguments, CommaProxyList):

/home/psycojoker/code/python/redbaron/redbaron/base_nodes.pyc in __setattr__(self, name, value)
   1006 
   1007         elif name in self._list_keys:
-> 1008             value = self._convert_input_to_node_object_list(value, self, name)
   1009 
   1010         return super(Node, self).__setattr__(name, value)

/home/psycojoker/code/python/redbaron/redbaron/base_nodes.pyc in _convert_input_to_node_object_list(self, value, parent, on_attribute)
    171     def _convert_input_to_node_object_list(self, value, parent, on_attribute):
    172         if isinstance(value, string_instance):
--> 173             return self._string_to_node_list(value, parent=parent, on_attribute=on_attribute)
    174 
    175         if isinstance(value, dict):  # assuming that we got some fst

/home/psycojoker/code/python/redbaron/redbaron/nodes.pyc in _string_to_node_list(self, string, parent, on_attribute)
    775 
    776         else:
--> 777             return super(DefNode, self)._string_to_node_list(string, parent, on_attribute)
    778 
    779     def _string_to_node(self, string, parent, on_attribute):

TypeError: super(type, obj): obj must be an instance or subtype of type

I haven't investigated what could be the reason.