microsoft / pyright

Static Type Checker for Python
Other
12.7k stars 1.35k forks source link

Use of variables in type expression are sometimes not reported #8316

Closed erictraut closed 1 week ago

erictraut commented 1 week ago

This comes from a mypy issue: https://github.com/python/mypy/issues/17493

The following code should generate an error:

from enum import Enum
from typing import Final, Literal

class Marker(Enum):
    unspecified = 0

unspecified: Final = Marker.unspecified

def func(value: int | Literal[unspecified] = unspecified) -> None:  # error: Parameter 1 of Literal[...] is invalid  [valid-type]
    ...
erictraut commented 1 week ago

This is addressed in pyright 1.1.371.