audeering / audobject

Generic Python interface for serializing objects to YAML
https://audeering.github.io/audobject/
Other
1 stars 0 forks source link

Fix default arguments in serialized functions #25

Closed frankenjoe closed 2 years ago

frankenjoe commented 2 years ago

Closes #24

I know found an easier way to dynamically create a function from code. The trick is to call exec() with a local namespace dictionary. This will create the function in the namespace, from which we can return it. This also preserves the defaults of the arguments. Since it does not work for lambda we stick to the old implementation in that case, which is fine since a lambda cannot have default arguments anyway.

codecov[bot] commented 2 years ago

Codecov Report

Merging #25 (aa2ff87) into master (930134b) will not change coverage. The diff coverage is 100.0%.

Impacted Files Coverage Δ
audobject/core/resolver.py 100.0% <100.0%> (ø)