@@ -13,7 +13,7 @@ b = None # type: B
13
13
14
14
ao = f()
15
15
ab = f()
16
- b = f() # E: Incompatible types in assignment (expression has type A[None ], variable has type "B")
16
+ b = f() # E: Incompatible types in assignment (expression has type A[<uninhabited> ], variable has type "B")
17
17
18
18
def f() -> 'A[T]': pass
19
19
@@ -29,7 +29,7 @@ b = None # type: B
29
29
30
30
ao = A()
31
31
ab = A()
32
- b = A() # E: Incompatible types in assignment (expression has type A[None ], variable has type "B")
32
+ b = A() # E: Incompatible types in assignment (expression has type A[<uninhabited> ], variable has type "B")
33
33
34
34
class A(Generic[T]): pass
35
35
class B: pass
@@ -334,7 +334,7 @@ aa = None # type: List[A]
334
334
ao = None # type: List[object]
335
335
a = None # type: A
336
336
337
- a = [] # E: Incompatible types in assignment (expression has type List[None ], variable has type "A")
337
+ a = [] # E: Incompatible types in assignment (expression has type List[<uninhabited> ], variable has type "A")
338
338
339
339
aa = []
340
340
ao = []
@@ -385,7 +385,7 @@ class B(A): pass
385
385
import typing
386
386
def f() -> None:
387
387
a = [] # E: Need type annotation for variable
388
- b = [None] # E: Need type annotation for variable
388
+ b = [None]
389
389
c = [B()]
390
390
c = [object()] # E: List item 0 has incompatible type "object"
391
391
c = [B()]
@@ -755,7 +755,7 @@ T = TypeVar('T')
755
755
def f(x: Union[List[T], str]) -> None: pass
756
756
f([1])
757
757
f('')
758
- f(1) # E: Argument 1 to "f" has incompatible type "int"; expected "Union[List[None ], str]"
758
+ f(1) # E: Argument 1 to "f" has incompatible type "int"; expected "Union[List[<uninhabited> ], str]"
759
759
[builtins fixtures/isinstancelist.pyi]
760
760
761
761
[case testIgnoringInferenceContext]
@@ -824,7 +824,7 @@ from typing import TypeVar, Callable, Generic
824
824
T = TypeVar('T')
825
825
class A(Generic[T]):
826
826
pass
827
- reveal_type(A()) # E: Revealed type is '__main__.A[builtins.None ]'
827
+ reveal_type(A()) # E: Revealed type is '__main__.A[<uninhabited> ]'
828
828
b = reveal_type(A()) # type: A[int] # E: Revealed type is '__main__.A[builtins.int]'
829
829
830
830
[case testUnionWithGenericTypeItemContext]
@@ -877,4 +877,17 @@ class M(Generic[_KT, _VT]):
877
877
def get(self, k: _KT, default: _T) -> _T: ...
878
878
879
879
def f(d: M[_KT, _VT], k: _KT) -> _VT:
880
+ return d.get(k, None) # E: "get" of "M" does not return a value
881
+
882
+ [case testGenericMethodCalledInGenericContext2]
883
+ from typing import TypeVar, Generic, Union
884
+
885
+ _KT = TypeVar('_KT')
886
+ _VT = TypeVar('_VT')
887
+ _T = TypeVar('_T')
888
+
889
+ class M(Generic[_KT, _VT]):
890
+ def get(self, k: _KT, default: _T) -> Union[_VT, _T]: ...
891
+
892
+ def f(d: M[_KT, _VT], k: _KT) -> Union[_VT, None]:
880
893
return d.get(k, None)
0 commit comments