pyre-check
pyre-check copied to clipboard
Does not understand instantiation of TypedDict defined within same function
trafficstars
Pyre Bug
Bug description Instantiation of a TypedDict which is defined within the same function (and not at the top-level of a module) is flagged incorrectly as a type error.
Reproduction steps
- Create this file:
# test.py
from typing import TypedDict
#class Movie(TypedDict):
# name: str
# year: int
def foo() -> None:
class Movie(TypedDict):
name: str
year: int
_2 = Movie(name="Blade Runner", year=1982)
foo()
- Setup Pyre:
pyre init(and everything else in the docs...) - Run Pyre with:
pyre - Does output type errors:
ƛ Found 1 type error!
test.py:12:9 Unexpected keyword [28]: Unexpected keyword argument `name` to call `object.__init__`.
If you move the definition of Movie to the top-level, the type error goes away.
Expected behavior There should be no type errors.
Additional context This bug was discovered while adding Pyre support to the trycast package.