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] = s
outputs:
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