redbaron
redbaron copied to clipboard
Assignment to atomtrailers index handled incorrectly
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()
Wow a case where replace() worked better than a simple assign? :trollface: Sorry for taking so long (hum) I'll get to this.