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.

classification
Title: proposal: add support for regex in Literal type hint
Type: Stage:
Components: Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: leon.mintz
Priority: normal Keywords:

Created on 2021-08-17 20:11 by leon.mintz, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg399787 - (view) Author: Leon Mintz (leon.mintz) Date: 2021-08-17 20:11
Could typing.Literal (or analogous) accept a regex pattern to match against?

For example, if I want a duration string,

duration: str  # allowed syntax: 3s, 3m, 3h etc.

vs

duration: LiteralPattern['[0-9]+[smh]']
History
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 89102
2021-08-17 20:11:12leon.mintzcreate