You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, a function with multiple typed arguments does not match a protocol that defines typed variadic arguments. I think many people have a use for typing these functions with a variadic callback protocol, especially when writing wrappers. I believe this is related to #5876, but extends the use of Any to other types.
Pitch
Many times it is useful to define a wrapper function with the signature wrapper(*args: T, **kwargs: Any) -> T, or something similar. This allows you to create a wrapper that is agnostic to the number of positional arguments, as long as they are all of the same type, with optional keyword arguments. This wrapper can then be applied to any number of functions that take in multiple positional arguments of the same type. For example:
This capability would extend the proposal in #5876 to still check for the argument types of the non-variadic functions, instead of just looking for Any. I think this would help alleviate typing headaches when trying to implement general wrappers and decorators.
The text was updated successfully, but these errors were encountered:
Feature
Currently, a function with multiple typed arguments does not match a protocol that defines typed variadic arguments. I think many people have a use for typing these functions with a variadic callback protocol, especially when writing wrappers. I believe this is related to #5876, but extends the use of
Any
to other types.Pitch
Many times it is useful to define a wrapper function with the signature
wrapper(*args: T, **kwargs: Any) -> T
, or something similar. This allows you to create a wrapper that is agnostic to the number of positional arguments, as long as they are all of the same type, with optional keyword arguments. This wrapper can then be applied to any number of functions that take in multiple positional arguments of the same type. For example:This capability would extend the proposal in #5876 to still check for the argument types of the non-variadic functions, instead of just looking for Any. I think this would help alleviate typing headaches when trying to implement general wrappers and decorators.
The text was updated successfully, but these errors were encountered: