summaryrefslogtreecommitdiff
path: root/tests/functional/t/typedDict.py
blob: 31cad0b28f3832207be4fb8c5febaaf20d35edd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Test typing.TypedDict"""
# pylint: disable=invalid-name,missing-class-docstring,pointless-statement
import typing
from typing import TypedDict


class CustomTD(TypedDict):
    var: int


class CustomTD2(typing.TypedDict, total=False):
    var2: str


class CustomTD3(CustomTD2):
    var3: int


CustomTD4 = TypedDict("CustomTD4", var4=bool)

CustomTD5 = TypedDict("CustomTD5", {"var5": bool})

my_dict = CustomTD(var=1)
my_dict["var"]
my_dict["var"] = 2


# https://github.com/pylint-dev/pylint/issues/4715
# Instance of TypedDict should be callable
Link = TypedDict("Link", {"href": str})
Link(href="foo")