@@ -187,10 +187,10 @@ class A:
187
187
reveal_type(A) # E: Revealed type is 'def (a: builtins.int) -> __main__.A'
188
188
reveal_type(A.__eq__) # E: Revealed type is 'def (self: __main__.A, other: builtins.object) -> builtins.bool'
189
189
reveal_type(A.__ne__) # E: Revealed type is 'def (self: __main__.A, other: builtins.object) -> builtins.bool'
190
- reveal_type(A.__lt__) # E: Revealed type is 'def [AT ] (self: AT `-1, other: AT `-1) -> builtins.bool'
191
- reveal_type(A.__le__) # E: Revealed type is 'def [AT ] (self: AT `-1, other: AT `-1) -> builtins.bool'
192
- reveal_type(A.__gt__) # E: Revealed type is 'def [AT ] (self: AT `-1, other: AT `-1) -> builtins.bool'
193
- reveal_type(A.__ge__) # E: Revealed type is 'def [AT ] (self: AT `-1, other: AT `-1) -> builtins.bool'
190
+ reveal_type(A.__lt__) # E: Revealed type is 'def [_AT ] (self: _AT `-1, other: _AT `-1) -> builtins.bool'
191
+ reveal_type(A.__le__) # E: Revealed type is 'def [_AT ] (self: _AT `-1, other: _AT `-1) -> builtins.bool'
192
+ reveal_type(A.__gt__) # E: Revealed type is 'def [_AT ] (self: _AT `-1, other: _AT `-1) -> builtins.bool'
193
+ reveal_type(A.__ge__) # E: Revealed type is 'def [_AT ] (self: _AT `-1, other: _AT `-1) -> builtins.bool'
194
194
195
195
A(1) < A(2)
196
196
A(1) <= A(2)
@@ -577,7 +577,10 @@ class C:
577
577
578
578
[builtins fixtures/list.pyi]
579
579
580
+ -- This is tricky with new analyzer:
581
+ -- We need to know the analyzed type of a function while still processing top-level.
580
582
[case testAttrsUsingBadConverter]
583
+ # flags: --no-new-semantic-analyzer --no-strict-optional
581
584
import attr
582
585
from typing import overload
583
586
@overload
@@ -596,11 +599,11 @@ class A:
596
599
bad_overloaded: int = attr.ib(converter=bad_overloaded_converter)
597
600
reveal_type(A)
598
601
[out]
599
- main:15: error: Cannot determine __init__ type from converter
600
- main:15: error: Argument "converter" has incompatible type "Callable[[], str]"; expected "Callable[[Any], str]"
601
602
main:16: error: Cannot determine __init__ type from converter
602
- main:16: error: Argument "converter" has incompatible type overloaded function; expected "Callable[[Any], int]"
603
- main:17: error: Revealed type is 'def (bad: Any, bad_overloaded: Any) -> __main__.A'
603
+ main:16: error: Argument "converter" has incompatible type "Callable[[], str]"; expected "Callable[[Any], str]"
604
+ main:17: error: Cannot determine __init__ type from converter
605
+ main:17: error: Argument "converter" has incompatible type overloaded function; expected "Callable[[Any], int]"
606
+ main:18: error: Revealed type is 'def (bad: Any, bad_overloaded: Any) -> __main__.A'
604
607
[builtins fixtures/list.pyi]
605
608
606
609
[case testAttrsUsingUnsupportedConverter]
@@ -667,10 +670,10 @@ class C(A, B): pass
667
670
@attr.s
668
671
class D(A): pass
669
672
670
- reveal_type(A.__lt__) # E: Revealed type is 'def [AT ] (self: AT `-1, other: AT `-1) -> builtins.bool'
671
- reveal_type(B.__lt__) # E: Revealed type is 'def [AT ] (self: AT `-1, other: AT `-1) -> builtins.bool'
672
- reveal_type(C.__lt__) # E: Revealed type is 'def [AT ] (self: AT `-1, other: AT `-1) -> builtins.bool'
673
- reveal_type(D.__lt__) # E: Revealed type is 'def [AT ] (self: AT `-1, other: AT `-1) -> builtins.bool'
673
+ reveal_type(A.__lt__) # E: Revealed type is 'def [_AT ] (self: _AT `-1, other: _AT `-1) -> builtins.bool'
674
+ reveal_type(B.__lt__) # E: Revealed type is 'def [_AT ] (self: _AT `-1, other: _AT `-1) -> builtins.bool'
675
+ reveal_type(C.__lt__) # E: Revealed type is 'def [_AT ] (self: _AT `-1, other: _AT `-1) -> builtins.bool'
676
+ reveal_type(D.__lt__) # E: Revealed type is 'def [_AT ] (self: _AT `-1, other: _AT `-1) -> builtins.bool'
674
677
675
678
A() < A()
676
679
B() < B()
0 commit comments