-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Description
Feature
Currently Literal doesn't accept another Literal or Final[Literal]. For example:
from typing_extensions import Final, Literal
s: Final[Literal['ccc']] = 'ccc'
s1: Literal[s] = soutputs:
a.py:4: error: Parameter 1 of Literal[...] is invalid
a.py:4: error: Variable "a.s" is not valid as a type
a.py:4: note: See https://mypy.readthedocs.io/en/latest/common_issues.html#variables-vs-type-aliases
Found 2 errors in 1 file (checked 1 source file)
Pitch
This is particularly useful when there are some defined constants and people refer to those constants rather than the actual value. For example, some of these socket constants: https://docs.python.org/3/library/socket.html#socket.BDADDR_ANY
p7g, mixilchenko, maratori, frerikandriessen, AlexWaygood and 5 moremaratorifilemon11, maratori, frerikandriessen and karolyjozsamaratorimaratori and frerikandriessen