Describe the bug
Type aliases for a literal types unexpectedly resolve to the parent collective type when they're declared inside a class body.
To Reproduce
from typing import Literal
LiteralAliasA = Literal['A']
class Foo:
LiteralAliasB = Literal['B']
LiteralAliasC1 = Literal['C', 1]
def bar(self, a: LiteralAliasA, b: LiteralAliasB, c1: LiteralAliasC1):
reveal_type(a)
reveal_type(b)
reveal_type(c1)
Expected behavior
Reveled types for parameters a, b, and c1 should be the relevant literal types defined above.
Actual behavior
Only a is typed correctly, b and c1 are typed as str and str | int, respectively.
VS Code extension or command-line
Running [email protected]
Additional comments
Not sure if it's somehow related to https://github.com/microsoft/pyright/issues/1050, but seemed different enough to report separately
Thanks for the bug report. This is a different issue from #1050. I've introduced a fix, and it will be in the next release.
This is now addressed in Pyright 1.1.74, which I just published. It will also be included in the next release of Pylance.