Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kwargs default value is not set after transformation #69

Open
yakobu opened this issue Jul 21, 2018 · 0 comments
Open

kwargs default value is not set after transformation #69

yakobu opened this issue Jul 21, 2018 · 0 comments

Comments

@yakobu
Copy link

yakobu commented Jul 21, 2018

from codetransformer import CodeTransformer, pattern
from codetransformer.instructions import BINARY_ADD, BINARY_MULTIPLY


class add2mul(CodeTransformer):
    @pattern(BINARY_ADD)
    def _add2mul(self, add_instr):
        yield BINARY_MULTIPLY().steal(add_instr)


def f(*, k=3):
    return k + 1


ff = add2mul()(f)

print(f.__kwdefaults__) => {'k': 3}
print(f()) => 4
print(ff.__kwdefaults__) => None
print(ff()) => TypeError: f() missing 1 required positional argument: 'k'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant