mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-16 10:37:52 +08:00
Merge branch 'typeddict' of https://github.com/pappasam/jedi
This commit is contained in:
@@ -499,3 +499,99 @@ def dynamic_annotation(x: int):
|
||||
|
||||
#? int()
|
||||
dynamic_annotation('')
|
||||
|
||||
# -------------------------
|
||||
# TypeDict
|
||||
# -------------------------
|
||||
|
||||
# python >= 3.8
|
||||
|
||||
class Foo(typing.TypedDict):
|
||||
foo: str
|
||||
bar: typing.List[float]
|
||||
an_int: int
|
||||
#! ['foo: str']
|
||||
foo
|
||||
#? str()
|
||||
foo
|
||||
#? int()
|
||||
an_int
|
||||
|
||||
def typed_dict_test_foo(arg: Foo):
|
||||
a_string = arg['foo']
|
||||
a_list_of_floats = arg['bar']
|
||||
an_int = arg['an_int']
|
||||
|
||||
#? str()
|
||||
a_string
|
||||
#? list()
|
||||
a_list_of_floats
|
||||
#? float()
|
||||
a_list_of_floats[0]
|
||||
#? int()
|
||||
an_int
|
||||
|
||||
#? ['isupper']
|
||||
a_string.isuppe
|
||||
#? ['pop']
|
||||
a_list_of_floats.po
|
||||
#? ['as_integer_ratio']
|
||||
an_int.as_integer_rati
|
||||
|
||||
#! ['class Foo']
|
||||
d: Foo
|
||||
#? str()
|
||||
d['foo']
|
||||
#? float()
|
||||
d['bar'][0]
|
||||
#?
|
||||
d['baz']
|
||||
|
||||
#?
|
||||
d.foo
|
||||
#?
|
||||
d.bar
|
||||
#! []
|
||||
d.foo
|
||||
|
||||
#? []
|
||||
Foo.set
|
||||
#? ['setdefault']
|
||||
d.setdefaul
|
||||
|
||||
#? 5 ["'foo"]
|
||||
d['fo']
|
||||
#? 5 ['"bar"']
|
||||
d["bar"]
|
||||
|
||||
class Bar(Foo):
|
||||
another_variable: int
|
||||
|
||||
#? int()
|
||||
another_variable
|
||||
#?
|
||||
an_int
|
||||
|
||||
def typed_dict_test_foo(arg: Bar):
|
||||
a_string = arg['foo']
|
||||
a_list_of_floats = arg['bar']
|
||||
an_int = arg['an_int']
|
||||
another_variable = arg['another_variable']
|
||||
|
||||
#? str()
|
||||
a_string
|
||||
#? list()
|
||||
a_list_of_floats
|
||||
#? float()
|
||||
a_list_of_floats[0]
|
||||
#? int()
|
||||
an_int
|
||||
#? int()
|
||||
another_variable
|
||||
|
||||
#? ['isupper']
|
||||
a_string.isuppe
|
||||
#? ['pop']
|
||||
a_list_of_floats.po
|
||||
#? ['as_integer_ratio']
|
||||
an_int.as_integer_rati
|
||||
|
||||
Reference in New Issue
Block a user