[prev in list] [next in list] [prev in thread] [next in thread]
List: python-ideas
Subject: [Python-ideas] Typing Callable Ellipsis -- support for type hints a la Callable[[int, float, ...], N
From: "Randolf Scholz" <randolf.scholz () gmail ! com>
Date: 2021-09-21 15:13:06
Message-ID: 163223718699.7037.17394273660350084610 () mail ! python ! org
[Download RAW message or body]
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-leave@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/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic