New submission from Pedro Torres :
Currently, the addition of Annotated in PEP 593 on Python 3.9 allows adding
arbitrary metadata for type hints.
Let's consider the following
time_available_online: list[str] =
[
'1m',
'5m',
'1d'
]
```
Hour = Annotated(str, "time available online")
```
Another way to consider this is if the selection was an Enum, since we know the
only available options that can be selected (ie. it is not all possible 'str',
only the 'str' from a list, which can be defined by the user)
It would save time and simplify things if the following was possible.
---
from typing import Enum # we save time by not making a duplicate Class, or
converting a constant variable to a Class
```
Hour = Enum[time_available_online, "time available online"]
```
--
components: Library (Lib)
messages: 411995
nosy: Corfucinas
priority: normal
severity: normal
status: open
title: Add typeof or eum behavior for in the Typing module
type: enhancement
versions: Python 3.10
___
Python tracker
<https://bugs.python.org/issue46562>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com