Create the basics to work with TypedDict in the future

This commit is contained in:
Dave Halter
2020-01-26 19:25:23 +01:00
parent 18f84d3af7
commit 8eb980db73
6 changed files with 156 additions and 3 deletions

View File

@@ -493,3 +493,44 @@ def dynamic_annotation(x: int):
#? int()
dynamic_annotation('')
# -------------------------
# TypeDict
# -------------------------
# python >= 3.8
class Foo(typing.TypedDict):
foo: str
bar: List[int]
foo
#! ['foo: str']
foo
#? str()
foo
#! ['class Foo']
d: Foo
#? str()
d['foo']
#? str()
d['bar'][0]
#?
d['baz']
#?
d.foo
#?
d.bar
#! []
d.foo
#? []
Foo.set
#? ['setdefault']
d.setdefaul
#? 5 ["'foo'"]
d['fo']
#? 5 ['"bar"']
d["bar"]