Bowler icon indicating copy to clipboard operation
Bowler copied to clipboard

Unable to chain remove_argument()

Open JohnVillalovos opened this issue 4 years ago • 5 comments

Using latest version from git as of today.

When trying to chain two remove_argument() functions I get the following error:

<snip>
  File "/home/jlvillal/.local/lib/python3.7/site-packages/bowler-0.8.0-py3.7.egg/bowler/query.py", line 892, in remove_argument_transform
    spec.explode()
  File "/home/jlvillal/.local/lib/python3.7/site-packages/bowler-0.8.0-py3.7.egg/bowler/imr.py", line 240, in explode
    self.capture["function_parameters"].replace(parameters)
  File "/home/jlvillal/.local/lib/python3.7/site-packages/fissix/pytree.py", line 108, in replace
    assert self.parent is not None, str(self)
AssertionError: ("P", 0, " --------------------")

JohnVillalovos avatar May 07 '20 17:05 JohnVillalovos

As a note, I worked around the issue by running one pass removing one argument and updating the file. Then running another pass to remove the second argument.

Also, this program was very useful in some refactoring work I had to do 👍

JohnVillalovos avatar May 07 '20 21:05 JohnVillalovos

If you have a more complete repro I can probably suggest other workarounds. Otherwise, doing it multiple phases would be my go-to.

thatch avatar May 25 '20 03:05 thatch

@JohnVillalovos do you by chance have a more complete repro yet?

thatch avatar Aug 11 '20 15:08 thatch

Actually, it would be nice to provide an example, my code is failing with this one:

raise ValueError("remove_argument requires passing original function")

Where can I specify it? Could you please provide the usage example? Thank you!

azachar avatar Mar 25 '21 01:03 azachar

@azachar I'm pretty sure your issue is just docs:

Where can I specify it?

instead of a string name, you have to import it first. See example at

https://gist.github.com/thatch/bb61a25c470d24934f7d4cf35da40f51 https://gist.github.com/thatch/1a5799c8d323b6ed3bc1e2e3f5f2c1b1

thatch avatar Apr 01 '21 14:04 thatch