codetransformer icon indicating copy to clipboard operation
codetransformer copied to clipboard

*args after transformation is considerd as a required positional argument

Open yakobu opened this issue 7 years ago • 1 comments

for example:

from codetransformer import CodeTransformer, pattern
from codetransformer.instructions import CALL_FUNCTION

def add(*args):
    return sum([*args])

class EmptyTransformer(CodeTransformer):
    @pattern(CALL_FUNCTION)
    def _call(self, call):
         yield call

transformer = EmptyTransformer()

new_add = transformer(add)

add() => 0
new_add() => TypeError: add() missing 1 required positional argument: 'args'

yakobu avatar Jul 07 '18 19:07 yakobu

Good find, it looks like we messed up how we represented this information between our Code object and the transformer.

I opened a PR to fix this here: https://github.com/llllllllll/codetransformer/pull/68

llllllllll avatar Jul 07 '18 20:07 llllllllll