-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
At the moment, if you try to define the following type,
from mypy_extensions import TypedDict
class GroupJSON(TypedDict):
""" JSON representation of group, received from API-endpoint """
group_name: str
you end up receiving an mypy error saying something along the lines of expected format 'key_name: value_type'
. Excuse me for not providing the exact error message, as I won't be able to use a computer for a couple of days.
It can be avoided by using the normal #
-comment syntax. It still came as a surprise when using this syntax. Most people are probably used to documenting classes with docstrings.
Perhaps this behaviour is intentional, as TypedDict
instances are interpreted as normal dictionaries at runtime? I would still argue that this is an implementation detail leaking through to the interface. Perhaps the docstring can be entirely ignored at runtime?
Thanks in advance,
Jakob
Metadata
Metadata
Assignees
Labels
No labels