redbaron icon indicating copy to clipboard operation
redbaron copied to clipboard

Assignment to atomtrailers index handled incorrectly

Open bmag opened this issue 10 years ago • 1 comments

Hi, I'm playing with the idea of creating a refactoring library on top of redbaron, and I've encountered a problem when assigning to an index of an AtomtrailersNode.

You can see for yourself:

>>> red = RedBaron('foo.real')
>>> red[0]
foo.real
>>> red[0].type
'atomtrailers'
>>> red[0][0] = 'random()'
>>> red[0] # expected result: random().real
().real
>>> red = RedBaron('foo.real')
>>> red[0][1] = 'random()'
>>> red[0] # expected result: foo.random()
foo()

Note that if I use replace, the result is as expected:

>>> red = RedBaron('foo.real')
>>> red[0][0].replace('random()')
>>> red[0]
random().real
>>> red = RedBaron('foo.real')
>>> red[0][1].replace('random()')
>>> red[0]
foo.random()

bmag avatar Aug 22 '15 07:08 bmag

Wow a case where replace() worked better than a simple assign? :trollface: Sorry for taking so long (hum) I'll get to this.

ibizaman avatar Dec 22 '16 07:12 ibizaman