Closed
Description
- Are you reporting a bug, or opening a feature request?
Bug (possibly, as per @ilevkivskyi on gitter)
Zach-Hammer:typedict zachhammer$ pipenv graph
mypy==0.660
- mypy-extensions [required: >=0.4.0,<0.5.0, installed: 0.4.1]
- typed-ast [required: >=1.2.0,<1.3.0, installed: 1.2.0]
Zach-Hammer:typedict zachhammer$ cat person.py
from mypy_extensions import TypedDict
class Person(TypedDict):
name: str
age: int
def api_fetch_person() -> Person:
return {
'name': 'Zach',
'age': 25,
'meta': 'other info'
}
Zach-Hammer:typedict zachhammer$ pipenv run mypy person.py
person.py:10: error: Extra key 'meta' for TypedDict "Person"
-
What is the actual behavior/output?
I have a TypedDictPerson
that has fieldsname
andage
I have a function that returns a dictionary withname
,age
, andmeta
mypy
throws error:Extra key 'meta' for TypedDict "Person"
-
What is the behavior/output you expect?
I was testing this out of curiosity, since it's not specified (as far as i can tell) in theTypedDict
documentation. I wanted to see if typeddict allowed extra, unspecified fields. (in which case it'd behave like a typescriptinterface
). I posted the outcome in the mypy gitter and @ilevkivskyi suggested I open an issue here. -
Do you see the same issue after installing mypy from Git master?
Can't do this at the moment but can try over the weekend