Skip to content

handle indented cases in CommaProxyList #100

Open
Pugio/redbaron
#1
@Psycojoker

Description

@Psycojoker

Quite a lot of work, we need to list/detect common situation where we could find an identation in a CommaList and see how we have to behave. Here is an example of a failing situation.

A "quick win" would be to have a default behavior (even a bad one) instead of an exception (which sucks).

In [7]: RedBaron("def __init__(self, a,\n   b, c): pass")[0].arguments.pop()
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-7-4d3f9b02d5b0> in <module>()
----> 1 RedBaron("def __init__(self, a,\n   b, c): pass")[0].arguments.pop()

/home/psycojoker/code/python/redbaron/redbaron/base_nodes.pyc in pop(self, index)
   1348         else:
   1349             self.data.pop()
-> 1350         self._synchronise()
   1351 
   1352     def remove(self, value):

/home/psycojoker/code/python/redbaron/redbaron/base_nodes.pyc in _synchronise(self)
   1325 
   1326     def _synchronise(self):
-> 1327         self.node_list.data = self._generate_expected_list()[:]
   1328         self.data = self._build_inner_list(self.node_list.data)
   1329 

/home/psycojoker/code/python/redbaron/redbaron/base_nodes.pyc in _generate_expected_list(self)
   1493                     if self.style == "indented":
   1494                         if not expected_list[-1].second_formatting.endl:
-> 1495                             raise Exception("Unhandled case")
   1496                         elif expected_list[-1].second_formatting.endl.indent != self.parent.indentation + " "*4:
   1497                             expected_list[-1].second_formatting.endl.indent = self.parent.indentation + " "*4

Exception: Unhandled case

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions