I want to write a function which adds a kwarg parameter to an existing library function.
The code part is easy:
def my_func(*args, new_kwarg: bool = True, **kwargs):
result = library_func(*args, **kwargs)
if new_kwarg:
result.do_something()
return result
However since the library function is very complex I’d like to keep the original type hints of the library function and add only the new key word parameter.
How do need to write the type hint? Concatenate does only work when passing in a function and then I can’t specify that it’s a kwarg parameter I want to add.
I would have expected this to work, but it does not:
No - since this adds no typing information at all.
Be aware that my issue is not with the implementation but with the type hint.
It’s not clear to me how I can “copy” the type hint from the library function to my own function.
Writing the code of the actual function is trivial as I showed above.
So I guess the only way to provide the proper type hint is to copy paste the three screens of overrides from the library?
Do you by chance know if there is something planned or do I just have to bite the bullet?