Prevent crash on generic NamedTuple with unresolved typevar bound by sterliakov · Pull Request #18585 · python/mypy (original) (raw)
Both primer hits appear to reveal a different problem, reproducible as follows:
[case testTemp]
foo = [
(1, ("a", "b")),
(2, []),
]
[builtins fixtures/tuple.pyi]
The inferred type is:
builtins.list[tuple[builtins.int, typing.Sequence[builtins.str]]]
nothing suspicious, but...
(Pdb) init_type.args[0].partial_fallback
builtins.tuple[Union[builtins.int, tuple[builtins.str, builtins.str], builtins.list[Never]], ...]
So when inferring list expr type as a constructor call, we synthetize a fully defined tuple with a partially unknown fallback (union of all initial values).
I think it's fine to keep for now and investigate separately?
And I'm still unable to write a testcase for the original problem, any suggestions are welcome!