This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Feature request: more typing.SupportsXXX
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.6
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: Siyuan Ren, gvanrossum, levkivskyi
Priority: normal Keywords:

Created on 2018-03-20 13:10 by Siyuan Ren, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg314141 - (view) Author: Siyuan Ren (Siyuan Ren) Date: 2018-03-20 13:10
Currently in module `typing` we have the following classes

* SupportsInt
* SupportsFloat
* SupportsComplex
* SupportsBytes
* SupportsRound

There is no reason that people only need these classes. They may need, say, `SupportsIndex` to denote all integer like types, `SupportsAdd` for arithmetic types, etc. It is best that the list of `SupportsXXX` are expanded to be as complete as possible, and even better, a mechanism for user specified `SupportsXXX` be provided.
msg314154 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2018-03-20 16:39
Such a mechanism exists, and is called Protocols. See PEP 544 ( While the PEP is still in draft, it is supported by mypy. You need to import the 'Protocol' base class from typing_extensions (which is a PyPI module, so use `pip install typing_extensions`).
Date User Action Args
2022-04-11 14:58:58adminsetgithub: 77288
2018-03-20 16:39:03gvanrossumsetstatus: open -> closed
resolution: works for me
messages: + msg314154

stage: resolved
2018-03-20 15:27:23ned.deilysetnosy: + gvanrossum, levkivskyi
2018-03-20 13:10:42Siyuan Rencreate