Skip to content

kwargs default value is not set after transformation #69

Open
@yakobu

Description

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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions