I have a function original
with specified arguments, their types and a doc-string.
How can I define a function new
that what that it would basically call original
but override a
argument with some A_DEFAULT
value. E.g. new(x) == original(A_DEFAULT, x)
.
The most important part is that resulting new
- should have original signature but without
a
argument - keep the original doc string
- both signature and doc string should be visible from IDE
The goal is to make those kind of partial functions without copying the original doc-strings and signatures explicitly.
Any ideas how it can be done? (even if you have some hacky idea)
import functools
A_DEFAULT = ...
def original(a: int, b: str):
"description"
return a + b
# `new` should have in IDE tooltips and type checks:
# - __doc__ = "description"
# - signature = (b: int)
# new(x) = original(A_DEFAULT, x)
new = ...