Dear Python community,

type hinting is awesome! But recently I stumbled upon the following: 
I was writing a dictionary of functions that all share a common signature, in 
that the first two arguments were the same type.
However, the functions could differ in the remaining arguments (positional / 
keyword)

When trying to type hint as `Callable[[int, float, ...], None] `, which felt 
very natural at the time, mypy complained: `error: Unexpected "..."`.

I propose to support type hints a la

- Callable[[type1, type2, ..., typeN, ...], ReturnType]
- Callable[[..., type1, type2, ..., typeN], ReturnType]

which should match any callable with matching type hints for the first/last N 
inputs. (with some special treatment for functions with *args or **kwargs of 
course).

Best regard, Randolf.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ILXWG2UIQI4HMFTENWNWHAKNSXG67D7N/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to