@@ -1540,6 +1540,8 @@ strict_optional = True
1540
1540
[[mypy-b]
1541
1541
strict_optional = False
1542
1542
1543
+ -- ]]
1544
+
1543
1545
[case testNewAnalyzerProperty]
1544
1546
class A:
1545
1547
@property
@@ -1920,3 +1922,78 @@ reveal_type(y[0]) # E: Revealed type is 'builtins.int'
1920
1922
x: A
1921
1923
reveal_type(x) # E: Revealed type is '__main__.G[Tuple[builtins.int, fallback=__main__.C]]'
1922
1924
[builtins fixtures/list.pyi]
1925
+
1926
+ [case testNewAnalyzerCastForward1]
1927
+ from typing import cast
1928
+
1929
+ x = cast('C', None)
1930
+ class A:
1931
+ def foo(self) -> None:
1932
+ self.x = cast('C', None)
1933
+
1934
+ reveal_type(x) # E: Revealed type is '__main__.C'
1935
+ reveal_type(A().x) # E: Revealed type is '__main__.C'
1936
+
1937
+ class C(A): ...
1938
+
1939
+ [case testNewAnalyzerCastForward2]
1940
+ from typing import cast
1941
+
1942
+ x = cast('C', None)
1943
+
1944
+ reveal_type(x) # E: Revealed type is 'builtins.int'
1945
+
1946
+ C = int
1947
+
1948
+ [case testNewAnalyzerCastForward2]
1949
+ from typing import cast, NamedTuple
1950
+
1951
+ x = cast('C', None)
1952
+
1953
+ reveal_type(x) # E: Revealed type is 'Tuple[builtins.int, fallback=__main__.C]'
1954
+ reveal_type(x.x) # E: Revealed type is 'builtins.int'
1955
+
1956
+ C = NamedTuple('C', [('x', int)])
1957
+
1958
+ [case testNewAnalyzerApplicationForward1]
1959
+ from typing import Generic, TypeVar
1960
+
1961
+ x = C[int]()
1962
+ reveal_type(x) # E: Revealed type is '__main__.C[builtins.int*]'
1963
+
1964
+ T = TypeVar('T')
1965
+ class C(Generic[T]): ...
1966
+
1967
+ [case testNewAnalyzerApplicationForward2]
1968
+ from typing import Generic, TypeVar
1969
+
1970
+ T = TypeVar('T')
1971
+ class C(Generic[T]): ...
1972
+
1973
+ x = C['A']()
1974
+ reveal_type(x) # E: Revealed type is '__main__.C[__main__.A*]'
1975
+
1976
+ class A: ...
1977
+
1978
+ [case testNewAnalyzerApplicationForward3]
1979
+ from typing import Generic, TypeVar
1980
+
1981
+ x = C[A]()
1982
+ reveal_type(x) # E: Revealed type is '__main__.C[__main__.A*]'
1983
+
1984
+ T = TypeVar('T')
1985
+ class C(Generic[T]): ...
1986
+
1987
+ class A: ...
1988
+
1989
+ [case testNewAnalyzerApplicationForward4]
1990
+ from typing import Generic, TypeVar
1991
+
1992
+ x = C[A]() # E: Value of type variable "T" of "C" cannot be "A"
1993
+ reveal_type(x) # E: Revealed type is '__main__.C[__main__.A*]'
1994
+
1995
+ T = TypeVar('T', bound='D')
1996
+ class C(Generic[T]): ...
1997
+
1998
+ class A: ...
1999
+ class D: ...
0 commit comments