So robotframework, Cadwyn, and apparently cattrs use this construct. These are libraries, yes, but regular business logic needs a similar structure for handling subclassing and super().__init__(*args, **kwargs)
too.
It feels to me like enough of a reason to add it to typing. If we were to ever add it to typing, what name would you folks prefer?
same_signature_as_in
copy_signature
same_definition_as_in
wraps
(please, don’t pick this one. I expect a lot of confusion from people, especially with auto-imports)
There is also an option of just improving support for functools.wraps
. However, functools.wraps
does not exactly do the same thing because it changes runtime attributes which might be an unwanted behavior in use cases of copy_signature
.
Additionally, there is a more complex option: we could draft how the more advanced function signature modification (people have mentioned it above in this thread) would look like in the future and then implement a small portion of that to just support copy_signature
. Though this one is probably the most dangerous option because if we get the future interface wrong, we are in for a lot of trouble, bad interfaces, and nasty deprecations. It is much easier to support a three-liner function that essentially does nothing at runtime.