@@ -2207,7 +2207,7 @@ reveal_type(Num3() + Num1()) # N: Revealed type is "__main__.Num3"
22072207reveal_type(Num2() + Num3()) # N: Revealed type is "__main__.Num2"
22082208reveal_type(Num3() + Num2()) # N: Revealed type is "__main__.Num3"
22092209
2210- [case testDivReverseOperatorPython3 ]
2210+ [case testDivReverseOperator ]
22112211# No error: __div__ has no special meaning in Python 3
22122212class A1:
22132213 def __div__(self, x: B1) -> int: ...
@@ -2222,37 +2222,6 @@ class B2:
22222222A1() / B1() # E: Unsupported left operand type for / ("A1")
22232223reveal_type(A2() / B2()) # N: Revealed type is "builtins.int"
22242224
2225- [case testDivReverseOperatorPython2]
2226- # flags: --python-version 2.7
2227-
2228- # Note: if 'from __future__ import division' is called, we use
2229- # __truediv__. Otherwise, we use __div__. So, we check both:
2230- class A1:
2231- def __div__(self, x):
2232- # type: (B1) -> int
2233- pass
2234- class B1:
2235- def __rdiv__(self, x): # E: Signatures of "__rdiv__" of "B1" and "__div__" of "A1" are unsafely overlapping
2236- # type: (A1) -> str
2237- pass
2238-
2239- class A2:
2240- def __truediv__(self, x):
2241- # type: (B2) -> int
2242- pass
2243- class B2:
2244- def __rtruediv__(self, x): # E: Signatures of "__rtruediv__" of "B2" and "__truediv__" of "A2" are unsafely overlapping
2245- # type: (A2) -> str
2246- pass
2247-
2248- # That said, mypy currently doesn't handle the actual division operation very
2249- # gracefully -- it doesn't correctly switch to using __truediv__ when
2250- # 'from __future__ import division' is included, it doesn't display a very
2251- # graceful error if __div__ is missing but __truediv__ is present...
2252- # Also see https://github.com/python/mypy/issues/2048
2253- reveal_type(A1() / B1()) # N: Revealed type is "builtins.int"
2254- A2() / B2() # E: "A2" has no attribute "__div__"
2255-
22562225[case testReverseOperatorMethodForwardIsAny]
22572226from typing import Any
22582227def deco(f: Any) -> Any: return f
@@ -2502,17 +2471,7 @@ reveal_type(B() + y) # N: Revealed type is "Union[__main__.Out2, __main__.Out4]
25022471reveal_type(x + C()) # N: Revealed type is "Union[__main__.Out3, __main__.Out2]"
25032472reveal_type(x + D()) # N: Revealed type is "Union[__main__.Out1, __main__.Out4]"
25042473
2505- [case testOperatorDoubleUnionDivisionPython2]
2506- # flags: --python-version 2.7
2507- from typing import Union
2508- def f(a):
2509- # type: (Union[int, float]) -> None
2510- a /= 1.1
2511- b = a / 1.1
2512- reveal_type(b) # N: Revealed type is "builtins.float"
2513- [builtins_py2 fixtures/ops.pyi]
2514-
2515- [case testOperatorDoubleUnionDivisionPython3]
2474+ [case testOperatorDoubleUnionDivision]
25162475from typing import Union
25172476def f(a):
25182477 # type: (Union[int, float]) -> None
@@ -5084,16 +5043,6 @@ reveal_type(type(A).x) # N: Revealed type is "builtins.int"
50845043reveal_type(type(B).x) # N: Revealed type is "builtins.int"
50855044[builtins fixtures/tuple.pyi]
50865045
5087- [case testSixMetaclass_python2]
5088- import six
5089- class M(type):
5090- x = 5
5091- class A(six.with_metaclass(M)): pass
5092- @six.add_metaclass(M)
5093- class B: pass
5094- reveal_type(type(A).x) # N: Revealed type is "builtins.int"
5095- reveal_type(type(B).x) # N: Revealed type is "builtins.int"
5096-
50975046[case testFromSixMetaclass]
50985047from six import with_metaclass, add_metaclass
50995048class M(type):
@@ -5217,13 +5166,6 @@ class CQA(Q1): pass # E: Inconsistent metaclass structure for "CQA"
52175166class CQW(six.with_metaclass(M, Q1)): pass # E: Inconsistent metaclass structure for "CQW"
52185167[builtins fixtures/tuple.pyi]
52195168
5220- [case testSixMetaclassErrors_python2]
5221- # flags: --python-version 2.7
5222- import six
5223- class M(type): pass
5224- class C4(six.with_metaclass(M)): # E: Multiple metaclass definitions
5225- __metaclass__ = M
5226-
52275169[case testSixMetaclassAny]
52285170import t # type: ignore
52295171import six
@@ -5244,13 +5186,6 @@ class A(future.utils.with_metaclass(M)): pass
52445186reveal_type(type(A).x) # N: Revealed type is "builtins.int"
52455187[builtins fixtures/tuple.pyi]
52465188
5247- [case testFutureMetaclass_python2]
5248- import future.utils
5249- class M(type):
5250- x = 5
5251- class A(future.utils.with_metaclass(M)): pass
5252- reveal_type(type(A).x) # N: Revealed type is "builtins.int"
5253-
52545189[case testFromFutureMetaclass]
52555190from future.utils import with_metaclass
52565191class M(type):
@@ -5336,13 +5271,6 @@ class Q1(metaclass=M1): pass
53365271class CQW(future.utils.with_metaclass(M, Q1)): pass # E: Inconsistent metaclass structure for "CQW"
53375272[builtins fixtures/tuple.pyi]
53385273
5339- [case testFutureMetaclassErrors_python2]
5340- # flags: --python-version 2.7
5341- import future.utils
5342- class M(type): pass
5343- class C4(future.utils.with_metaclass(M)): # E: Multiple metaclass definitions
5344- __metaclass__ = M
5345-
53465274[case testFutureMetaclassAny]
53475275import t # type: ignore
53485276import future.utils
@@ -7323,7 +7251,7 @@ def foo(self: Any) -> str:
73237251from typing import Any, Callable, TypeVar
73247252
73257253class Parent:
7326- foo = Callable[..., int]
7254+ foo = Callable[..., int]
73277255 class bar:
73287256 pass
73297257 import typing as baz
0 commit comments