File tree Expand file tree Collapse file tree 4 files changed +33
-15
lines changed Expand file tree Collapse file tree 4 files changed +33
-15
lines changed Original file line number Diff line number Diff line change @@ -121,17 +121,25 @@ A().f = None # E: Cannot assign to a method
121
121
122
122
[case testReferToInvalidAttribute]
123
123
124
+ class A:
125
+ def __init__(self) -> None:
126
+ self.x = object()
127
+ a: A
128
+ a.y # E: "A" has no attribute "y"
129
+ a.y = object() # E: "A" has no attribute "y"
130
+ a.x
131
+ a.x = object()
132
+
133
+ [case testReferToInvalidAttributeUnannotatedInit]
124
134
class A:
125
135
def __init__(self):
126
136
self.x = object()
127
- a = None # type: A
128
- a.y
129
- a.y = object()
137
+
138
+ a: A
139
+ a.y # E: "A" has no attribute "y"
140
+ a.y = object() # E: "A" has no attribute "y"
130
141
a.x
131
142
a.x = object()
132
- [out]
133
- main:6: error: "A" has no attribute "y"
134
- main:7: error: "A" has no attribute "y"
135
143
136
144
[case testArgumentTypeInference]
137
145
Original file line number Diff line number Diff line change @@ -1403,10 +1403,15 @@ b[{}] = 1
1403
1403
1404
1404
[case testInferDictInitializedToEmptyAndUpdatedFromMethod]
1405
1405
map = {}
1406
+ def add() -> None:
1407
+ map[1] = 2
1408
+ [builtins fixtures/dict.pyi]
1409
+
1410
+ [case testInferDictInitializedToEmptyAndUpdatedFromMethodUnannotated]
1411
+ map = {}
1406
1412
def add():
1407
1413
map[1] = 2
1408
1414
[builtins fixtures/dict.pyi]
1409
- [out]
1410
1415
1411
1416
[case testSpecialCaseEmptyListInitialization]
1412
1417
def f(blocks: Any): # E: Name 'Any' is not defined
@@ -1959,7 +1964,7 @@ class C:
1959
1964
1960
1965
if bool():
1961
1966
f()
1962
- 1 + '' # E: Unsupported left operand type for + ( "int")
1967
+ 1() # E: "int" not callable
1963
1968
[builtins fixtures/list.pyi]
1964
1969
[out]
1965
1970
@@ -1976,7 +1981,7 @@ class C:
1976
1981
1977
1982
if bool():
1978
1983
f()
1979
- 1 + '' # E: Unsupported left operand type for + ( "int")
1984
+ 1() # E: "int" not callable
1980
1985
[builtins fixtures/list.pyi]
1981
1986
[out]
1982
1987
@@ -1992,6 +1997,6 @@ class C:
1992
1997
1993
1998
if bool():
1994
1999
f([])
1995
- 1 + '' # E: Unsupported left operand type for + ( "int")
2000
+ 1() # E: "int" not callable
1996
2001
[builtins fixtures/list.pyi]
1997
2002
[out]
Original file line number Diff line number Diff line change @@ -1312,9 +1312,14 @@ class A:
1312
1312
def f(self) -> str: return 'foo'
1313
1313
class B(A):
1314
1314
def f(self) -> str: return self.x
1315
- def initialize(self): self.x = 'bar'
1316
- [out]
1315
+ def initialize(self) -> None: self.x = 'bar'
1317
1316
1317
+ [case testDeferredClassContextUnannotated]
1318
+ class A:
1319
+ def f(self) -> str: return 'foo'
1320
+ class B(A):
1321
+ def f(self) -> str: return self.x
1322
+ def initialize(self): self.x = 'bar'
1318
1323
1319
1324
-- Scripts and __main__
1320
1325
Original file line number Diff line number Diff line change @@ -353,12 +353,12 @@ a @= 1 # E: Argument 1 to "__imatmul__" of "A" has incompatible type "int"; exp
353
353
354
354
[case testInplaceSetitem]
355
355
class A(object):
356
- def __init__(self):
357
- self.a = 0
356
+ def __init__(self) -> None :
357
+ self.a = [1]
358
358
359
359
def __iadd__(self, a):
360
360
# type: (int) -> A
361
- self.a += 1
361
+ self.a += [2]
362
362
return self
363
363
364
364
a = A()
You can’t perform that action at this time.
0 commit comments