Thanks for this Anthony!! This gave some insight for type hinting *args and **kwargs!
@erwan51124 жыл бұрын
This means less libraries exposing `some_func(*args:Any, **kwargs: Any) -> Any` which wraps a function which wraps a function where arguments are finally defined? Amazing! Last time I ended up redefining the API subset I was using: def typed_wrapper( arg1: str, arg2: int, arg3: Tuple[str, str] ) -> int: kwargs = rebuild_kwargs(locals()) return untyped_function(**kwargs) With this to rebuild kwargs: gist.github.com/tools4origins/e1962a9edb3734ad47f5e5ca7be34697
@anthonywritescode4 жыл бұрын
that function looks a bit scary! why not just `**locals()` at that point (or I guess that would limit you based on the assignments in the rest of the function)
@erwan51124 жыл бұрын
🤯 it does work in most cases indeed
@esparafucio Жыл бұрын
I'm still struggling to understand the syntax exactly, say I have a class from a module: class MyClass(module.Class): def __init__(self, *args: Any, **kwargs: Any): super.__init__(*args, **kwargs) How would I annotate that to avoid Any?