Merge branch 'master' into refactor

This commit is contained in:
Dave Halter
2020-03-13 23:53:09 +01:00
29 changed files with 331 additions and 54 deletions

View File

@@ -422,3 +422,11 @@ with Foo() as f3:
#? 6 Foo
with Foo() as f3:
f3
# -----------------
# Avoiding multiple definitions
# -----------------
some_array = ['', '']
#! ['def upper']
some_array[some_not_defined_index].upper

View File

@@ -499,3 +499,89 @@ 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
#? []
Foo.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):
#? str()
arg['foo']
#? list()
arg['bar']
#? float()
arg['bar'][0]
#? int()
arg['an_int']
#? int()
arg['another_variable']

View File

@@ -57,7 +57,7 @@ Foo.baz
Foo().baz
class VarClass:
var_instance1: int = 1
var_instance1: int = ''
var_instance2: float
var_class1: typing.ClassVar[str] = 1
var_class2: typing.ClassVar[bytes]
@@ -77,9 +77,9 @@ class VarClass:
self.var_
#? ['var_class1', 'var_class2']
#? ['var_class1', 'var_class2', 'var_instance1']
VarClass.var_
#?
#? int()
VarClass.var_instance1
#?
VarClass.var_instance2

View File

@@ -91,3 +91,15 @@ class B:
for i in self.a(i):
#?
yield i
foo = int
foo = foo # type: foo
#? int
foo
while True:
bar = int
bar = bar # type: bar
#? int()
bar