Describe the bug
When checking the existence of a key in a TypedDict which has extra_items defined, the unreachability analysis seems to assume every key is present.
Testing a normally defined key in the same dict behaves as expected.
Code or Screenshots
In the code below, pyright claims the print statement is never reached.
from typing import TypedDict
class Typed(TypedDict, extra_items=str):
a: str
def test(d: Typed) -> None:
if "b" in d:
return
print("here")
https://pyright-play.net/?strict=true&code=GYJw9gtgBALgngBwJYDsDmUkQWEMoAqiApgCYAiSAxjAFC1UA2AhgM6uEmkAURCZlGgBooxAB4wQzAPpIYxCKwC8rSQEoAXLSg6ozDVFUh6pYsFjFV3Ugb5k1UALQA%2BKADkwKYlt2ZzAIgAjf0wUKBttX10QYhgAVxAUSJ0EEFQYbn8AC2IY-zVaIA
VS Code extension or command-line
pyright 1.1409
Describe the bug
When checking the existence of a key in a
TypedDictwhich hasextra_itemsdefined, the unreachability analysis seems to assume every key is present.Testing a normally defined key in the same dict behaves as expected.
Code or Screenshots
In the code below, pyright claims the
printstatement is never reached.https://pyright-play.net/?strict=true&code=GYJw9gtgBALgngBwJYDsDmUkQWEMoAqiApgCYAiSAxjAFC1UA2AhgM6uEmkAURCZlGgBooxAB4wQzAPpIYxCKwC8rSQEoAXLSg6ozDVFUh6pYsFjFV3Ugb5k1UALQA%2BKADkwKYlt2ZzAIgAjf0wUKBttX10QYhgAVxAUSJ0EEFQYbn8AC2IY-zVaIA
VS Code extension or command-line
pyright 1.1409