Welcome!
The first question I have is: what is the use case you are trying to
support here? The ones that comes to mind for me is making it explicit to
the type checker what the value type of an enum is:
class StringEnum(Enum[str]):
a = "a string"
b = "another string"
class TupleEnum(Enum[tuple[int, int]]):
a = (1, 2)
b = (2, 3)
That seems useful, but it's not too important as type checkers can already
infer the value type from the class body.
Or is there some other use case I am missing?
El dom, 23 ene 2022 a las 9:47, Ethan Furman (
Greetings!
I'd like to add Generics support for Enum... at least I think I do. :-/
The magic seems to happen in `SomeMetaClass.__getitem__`, and it should be doable as `EnumType.__getitem__` currently only accepts strings
Note though that strings can be valid types (for forward annotations), so if SomeEnum[T] meant something related to generics, it may be difficult to distinguish it from the current support for SomeEnum[name] == getattr(SomeEnum, name).
, so types could easily take a different branch in the code, but I am entirely unsure of what that separate branch should do, what it should return, etc.
Are there any pure-python classes in the stdlib (besides Generics) that I could use for inspiration? Or some documentation somewhere I could use? A basic tutorial so I can get a grip on all the terminology?
Any and all help appreciated!
-- ~Ethan~ _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: jelle.zijlstra@gmail.com