Why doesn't stubgen generate types for literal collections?

52 views Asked by At

For example, on this file:

MY_DICT = {'a': 0, 'b': 1, 'c': 2}
MY_LIST = ['a', 'b', 'c']
MY_TUPLE = ('a', 'b', 'c')

It generates:

from _typeshed import Incomplete

MY_DICT: Incomplete
MY_LIST: Incomplete
MY_TUPLE: Incomplete

I would have expected:

MY_DICT: dict[str, int]
MY_LIST: list[str]
MY_TUPLE: tuple[str]

Why can't it infer it? Or does it operate on the premise that the values can change and we can only really know what the intended type is from a handwritten annotation?

0

There are 0 answers