@@ -4745,7 +4745,7 @@ main:12: note: @overload
4745
4745
main:12: note: def __add__(self, Other, /) -> B
4746
4746
main:12: note: @overload
4747
4747
main:12: note: def __add__(self, A, /) -> A
4748
- main:12: note: Overloaded operator methods cannot have wider argument types in overrides
4748
+ main:12: note: Overloaded operator methods can't have wider argument types in overrides
4749
4749
main:32: note: Revealed type is "__main__.Other"
4750
4750
4751
4751
[case testOverloadErrorMessageManyMatches]
@@ -5405,26 +5405,26 @@ if False:
5405
5405
def f2(g): ...
5406
5406
reveal_type(f2(A())) # N: Revealed type is "__main__.A"
5407
5407
reveal_type(f2(C())) # E: No overload variant of "f2" matches argument type "C" \
5408
- # N: Possible overload variants: \
5409
- # N: def f2(g: A) -> A \
5410
- # N: def f2(g: B) -> B \
5411
- # N: Revealed type is "Any"
5408
+ # N: Possible overload variants: \
5409
+ # N: def f2(g: A) -> A \
5410
+ # N: def f2(g: B) -> B \
5411
+ # N: Revealed type is "Any"
5412
5412
5413
5413
@overload
5414
5414
def f3(g: A) -> A: ...
5415
5415
@overload
5416
5416
def f3(g: B) -> B: ...
5417
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
5417
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
5418
5418
# E: Name "maybe_true" is not defined
5419
5419
@overload
5420
5420
def f3(g: C) -> C: ...
5421
5421
def f3(g): ...
5422
5422
reveal_type(f3(A())) # N: Revealed type is "__main__.A"
5423
5423
reveal_type(f3(C())) # E: No overload variant of "f3" matches argument type "C" \
5424
- # N: Possible overload variants: \
5425
- # N: def f3(g: A) -> A \
5426
- # N: def f3(g: B) -> B \
5427
- # N: Revealed type is "Any"
5424
+ # N: Possible overload variants: \
5425
+ # N: def f3(g: A) -> A \
5426
+ # N: def f3(g: B) -> B \
5427
+ # N: Revealed type is "Any"
5428
5428
5429
5429
if True:
5430
5430
@overload
@@ -5731,10 +5731,10 @@ def f1(x): ...
5731
5731
reveal_type(f1(A())) # N: Revealed type is "__main__.A"
5732
5732
reveal_type(f1(B())) # N: Revealed type is "__main__.B"
5733
5733
reveal_type(f1(D())) # E: No overload variant of "f1" matches argument type "D" \
5734
- # N: Possible overload variants: \
5735
- # N: def f1(x: A) -> A \
5736
- # N: def f1(x: B) -> B \
5737
- # N: Revealed type is "Any"
5734
+ # N: Possible overload variants: \
5735
+ # N: def f1(x: A) -> A \
5736
+ # N: def f1(x: B) -> B \
5737
+ # N: Revealed type is "Any"
5738
5738
5739
5739
@overload
5740
5740
def f2(x: A) -> A: ...
@@ -5751,14 +5751,14 @@ def f2(x): ...
5751
5751
reveal_type(f2(A())) # N: Revealed type is "__main__.A"
5752
5752
reveal_type(f2(B())) # N: Revealed type is "__main__.B"
5753
5753
reveal_type(f2(C())) # E: No overload variant of "f2" matches argument type "C" \
5754
- # N: Possible overload variants: \
5755
- # N: def f2(x: A) -> A \
5756
- # N: def f2(x: B) -> B \
5757
- # N: Revealed type is "Any"
5754
+ # N: Possible overload variants: \
5755
+ # N: def f2(x: A) -> A \
5756
+ # N: def f2(x: B) -> B \
5757
+ # N: Revealed type is "Any"
5758
5758
5759
5759
@overload # E: Single overload definition, multiple required
5760
5760
def f3(x: A) -> A: ...
5761
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
5761
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
5762
5762
# E: Name "maybe_true" is not defined
5763
5763
@overload
5764
5764
def f3(x: B) -> B: ...
@@ -5771,13 +5771,13 @@ else:
5771
5771
def f3(x): ...
5772
5772
reveal_type(f3(A())) # N: Revealed type is "__main__.A"
5773
5773
reveal_type(f3(B())) # E: No overload variant of "f3" matches argument type "B" \
5774
- # N: Possible overload variant: \
5775
- # N: def f3(x: A) -> A \
5776
- # N: Revealed type is "Any"
5774
+ # N: Possible overload variant: \
5775
+ # N: def f3(x: A) -> A \
5776
+ # N: Revealed type is "Any"
5777
5777
5778
5778
@overload # E: Single overload definition, multiple required
5779
5779
def f4(x: A) -> A: ...
5780
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
5780
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
5781
5781
# E: Name "maybe_true" is not defined
5782
5782
@overload
5783
5783
def f4(x: B) -> B: ...
@@ -5787,9 +5787,10 @@ else:
5787
5787
def f4(x): ...
5788
5788
reveal_type(f4(A())) # N: Revealed type is "__main__.A"
5789
5789
reveal_type(f4(B())) # E: No overload variant of "f4" matches argument type "B" \
5790
- # N: Possible overload variant: \
5791
- # N: def f4(x: A) -> A \
5792
- # N: Revealed type is "Any"
5790
+ # N: Possible overload variant: \
5791
+ # N: def f4(x: A) -> A \
5792
+ # N: Revealed type is "Any"
5793
+
5793
5794
5794
5795
[case testOverloadIfElse3]
5795
5796
# flags: --always-false False
@@ -5817,18 +5818,18 @@ else:
5817
5818
def f1(x): ...
5818
5819
reveal_type(f1(A())) # N: Revealed type is "__main__.A"
5819
5820
reveal_type(f1(B())) # E: No overload variant of "f1" matches argument type "B" \
5820
- # N: Possible overload variants: \
5821
- # N: def f1(x: A) -> A \
5822
- # N: def f1(x: D) -> D \
5823
- # N: Revealed type is "Any"
5821
+ # N: Possible overload variants: \
5822
+ # N: def f1(x: A) -> A \
5823
+ # N: def f1(x: D) -> D \
5824
+ # N: Revealed type is "Any"
5824
5825
reveal_type(f1(D())) # N: Revealed type is "__main__.D"
5825
5826
5826
5827
@overload # E: Single overload definition, multiple required
5827
5828
def f2(x: A) -> A: ...
5828
5829
if False:
5829
5830
@overload
5830
5831
def f2(x: B) -> B: ...
5831
- elif maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
5832
+ elif maybe_true: # E: Condition can't be inferred, unable to merge overloads \
5832
5833
# E: Name "maybe_true" is not defined
5833
5834
@overload
5834
5835
def f2(x: C) -> C: ...
@@ -5838,13 +5839,13 @@ else:
5838
5839
def f2(x): ...
5839
5840
reveal_type(f2(A())) # N: Revealed type is "__main__.A"
5840
5841
reveal_type(f2(C())) # E: No overload variant of "f2" matches argument type "C" \
5841
- # N: Possible overload variant: \
5842
- # N: def f2(x: A) -> A \
5843
- # N: Revealed type is "Any"
5842
+ # N: Possible overload variant: \
5843
+ # N: def f2(x: A) -> A \
5844
+ # N: Revealed type is "Any"
5844
5845
5845
5846
@overload # E: Single overload definition, multiple required
5846
5847
def f3(x: A) -> A: ...
5847
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
5848
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
5848
5849
# E: Name "maybe_true" is not defined
5849
5850
@overload
5850
5851
def f3(x: B) -> B: ...
@@ -5857,14 +5858,14 @@ else:
5857
5858
def f3(x): ...
5858
5859
reveal_type(f3(A())) # N: Revealed type is "__main__.A"
5859
5860
reveal_type(f3(B())) # E: No overload variant of "f3" matches argument type "B" \
5860
- # N: Possible overload variant: \
5861
- # N: def f3(x: A) -> A \
5862
- # N: Revealed type is "Any"
5861
+ # N: Possible overload variant: \
5862
+ # N: def f3(x: A) -> A \
5863
+ # N: Revealed type is "Any"
5863
5864
5864
5865
def g(bool_var: bool) -> None:
5865
5866
@overload
5866
5867
def f4(x: A) -> A: ...
5867
- if bool_var: # E: Condition cannot be inferred, unable to merge overloads
5868
+ if bool_var: # E: Condition can't be inferred, unable to merge overloads
5868
5869
@overload
5869
5870
def f4(x: B) -> B: ...
5870
5871
elif maybe_true: # E: Name "maybe_true" is not defined
@@ -5880,10 +5881,11 @@ def g(bool_var: bool) -> None:
5880
5881
def f4(x): ...
5881
5882
reveal_type(f4(E())) # N: Revealed type is "__main__.E"
5882
5883
reveal_type(f4(B())) # E: No overload variant of "f4" matches argument type "B" \
5883
- # N: Possible overload variants: \
5884
- # N: def f4(x: A) -> A \
5885
- # N: def f4(x: E) -> E \
5886
- # N: Revealed type is "Any"
5884
+ # N: Possible overload variants: \
5885
+ # N: def f4(x: A) -> A \
5886
+ # N: def f4(x: E) -> E \
5887
+ # N: Revealed type is "Any"
5888
+
5887
5889
5888
5890
[case testOverloadIfSkipUnknownExecution]
5889
5891
# flags: --always-true True
@@ -5901,14 +5903,14 @@ class D: ...
5901
5903
5902
5904
@overload # E: Single overload definition, multiple required
5903
5905
def f1(x: A) -> A: ...
5904
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
5906
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
5905
5907
# E: Name "maybe_true" is not defined
5906
5908
@overload
5907
5909
def f1(x: B) -> B: ...
5908
5910
def f1(x): ...
5909
5911
reveal_type(f1(A())) # N: Revealed type is "__main__.A"
5910
5912
5911
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
5913
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
5912
5914
# E: Name "maybe_true" is not defined
5913
5915
@overload
5914
5916
def f2(x: A) -> A: ...
@@ -5918,23 +5920,23 @@ def f2(x: B) -> B: ...
5918
5920
def f2(x: C) -> C: ...
5919
5921
def f2(x): ...
5920
5922
reveal_type(f2(A())) # E: No overload variant of "f2" matches argument type "A" \
5921
- # N: Possible overload variants: \
5922
- # N: def f2(x: B) -> B \
5923
- # N: def f2(x: C) -> C \
5924
- # N: Revealed type is "Any"
5923
+ # N: Possible overload variants: \
5924
+ # N: def f2(x: B) -> B \
5925
+ # N: def f2(x: C) -> C \
5926
+ # N: Revealed type is "Any"
5925
5927
5926
5928
if True:
5927
5929
@overload # E: Single overload definition, multiple required
5928
5930
def f3(x: A) -> A: ...
5929
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
5931
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
5930
5932
# E: Name "maybe_true" is not defined
5931
5933
@overload
5932
5934
def f3(x: B) -> B: ...
5933
5935
def f3(x): ...
5934
5936
reveal_type(f3(A())) # N: Revealed type is "__main__.A"
5935
5937
5936
5938
if True:
5937
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
5939
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
5938
5940
# E: Name "maybe_true" is not defined
5939
5941
@overload
5940
5942
def f4(x: A) -> A: ...
@@ -5944,10 +5946,10 @@ if True:
5944
5946
def f4(x: C) -> C: ...
5945
5947
def f4(x): ...
5946
5948
reveal_type(f4(A())) # E: No overload variant of "f4" matches argument type "A" \
5947
- # N: Possible overload variants: \
5948
- # N: def f4(x: B) -> B \
5949
- # N: def f4(x: C) -> C \
5950
- # N: Revealed type is "Any"
5949
+ # N: Possible overload variants: \
5950
+ # N: def f4(x: B) -> B \
5951
+ # N: def f4(x: C) -> C \
5952
+ # N: Revealed type is "Any"
5951
5953
5952
5954
[case testOverloadIfDontSkipUnrelatedOverload]
5953
5955
# flags: --always-true True
@@ -6187,16 +6189,16 @@ if False:
6187
6189
def f8(x): ...
6188
6190
reveal_type(f8(A())) # N: Revealed type is "__main__.A"
6189
6191
reveal_type(f8(C())) # E: No overload variant of "f8" matches argument type "C" \
6190
- # N: Possible overload variants: \
6191
- # N: def f8(x: A) -> A \
6192
- # N: def f8(x: B) -> B \
6193
- # N: Revealed type is "Any"
6192
+ # N: Possible overload variants: \
6193
+ # N: def f8(x: A) -> A \
6194
+ # N: def f8(x: B) -> B \
6195
+ # N: Revealed type is "Any"
6194
6196
6195
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
6197
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
6196
6198
# E: Name "maybe_true" is not defined
6197
6199
@overload
6198
6200
def f9(x: A) -> A: ...
6199
- if another_maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
6201
+ if another_maybe_true: # E: Condition can't be inferred, unable to merge overloads \
6200
6202
# E: Name "another_maybe_true" is not defined
6201
6203
@overload
6202
6204
def f9(x: B) -> B: ...
@@ -6206,18 +6208,18 @@ def f9(x: C) -> C: ...
6206
6208
def f9(x: D) -> D: ...
6207
6209
def f9(x): ...
6208
6210
reveal_type(f9(A())) # E: No overload variant of "f9" matches argument type "A" \
6209
- # N: Possible overload variants: \
6210
- # N: def f9(x: C) -> C \
6211
- # N: def f9(x: D) -> D \
6212
- # N: Revealed type is "Any"
6211
+ # N: Possible overload variants: \
6212
+ # N: def f9(x: C) -> C \
6213
+ # N: def f9(x: D) -> D \
6214
+ # N: Revealed type is "Any"
6213
6215
reveal_type(f9(C())) # N: Revealed type is "__main__.C"
6214
6216
6215
6217
if True:
6216
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
6218
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
6217
6219
# E: Name "maybe_true" is not defined
6218
6220
@overload
6219
6221
def f10(x: A) -> A: ...
6220
- if another_maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
6222
+ if another_maybe_true: # E: Condition can't be inferred, unable to merge overloads \
6221
6223
# E: Name "another_maybe_true" is not defined
6222
6224
@overload
6223
6225
def f10(x: B) -> B: ...
@@ -6227,10 +6229,10 @@ if True:
6227
6229
def f10(x: D) -> D: ...
6228
6230
def f10(x): ...
6229
6231
reveal_type(f10(A())) # E: No overload variant of "f10" matches argument type "A" \
6230
- # N: Possible overload variants: \
6231
- # N: def f10(x: C) -> C \
6232
- # N: def f10(x: D) -> D \
6233
- # N: Revealed type is "Any"
6232
+ # N: Possible overload variants: \
6233
+ # N: def f10(x: C) -> C \
6234
+ # N: def f10(x: D) -> D \
6235
+ # N: Revealed type is "Any"
6234
6236
reveal_type(f10(C())) # N: Revealed type is "__main__.C"
6235
6237
6236
6238
if some_var: # E: Name "some_var" is not defined
@@ -6251,6 +6253,7 @@ if True:
6251
6253
def f12(x: B) -> B: ...
6252
6254
def f12(x): ...
6253
6255
reveal_type(f12(A())) # N: Revealed type is "__main__.A"
6256
+
6254
6257
[typing fixtures/typing-medium.pyi]
6255
6258
6256
6259
[case testOverloadIfUnconditionalFuncDef]
@@ -6406,7 +6409,7 @@ def f1(g: A) -> A: ...
6406
6409
if True:
6407
6410
@overload # E: Single overload definition, multiple required
6408
6411
def f1(g: B) -> B: ...
6409
- if maybe_true: # E: Condition cannot be inferred, unable to merge overloads \
6412
+ if maybe_true: # E: Condition can't be inferred, unable to merge overloads \
6410
6413
# E: Name "maybe_true" is not defined
6411
6414
@overload
6412
6415
def f1(g: C) -> C: ...
@@ -6432,7 +6435,7 @@ if True:
6432
6435
def f3(g: B) -> B: ...
6433
6436
if True:
6434
6437
pass # Some other node
6435
- @overload # E: Name "f3" already defined on line 32 \
6438
+ @overload # E: Name "f3" already defined on line 32 \
6436
6439
# E: An overloaded function outside a stub file must have an implementation
6437
6440
def f3(g: C) -> C: ...
6438
6441
@overload
0 commit comments