Skip to content

Commit 74f5a57

Browse files
committed
Restrict to cases with args formatted to the same string
1 parent c64d00b commit 74f5a57

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mypy/messages.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,6 +2856,9 @@ def format_type_distinctly(*types: Type, options: Options, bare: bool = False) -
28562856
"""
28572857
overlapping = find_type_overlaps(*types)
28582858

2859+
def format_single(arg: Type) -> str:
2860+
return format_type_inner(arg, verbosity=0, options=options, fullnames=overlapping)
2861+
28592862
min_verbosity = 0
28602863
# Prevent emitting weird errors like:
28612864
# ... has incompatible type "Callable[[int], Child]"; expected "Callable[[int], Parent]"
@@ -2871,6 +2874,11 @@ def format_type_distinctly(*types: Type, options: Options, bare: bool = False) -
28712874
and isinstance(right, CallableType)
28722875
and is_subtype(left.ret_type, right.ret_type)
28732876
and any(right.arg_names)
2877+
and len(right.arg_types) == len(left.arg_types)
2878+
and all(
2879+
format_single(aleft) == format_single(aright)
2880+
for aleft, aright in zip(left.arg_types, right.arg_types)
2881+
)
28742882
):
28752883
min_verbosity = 1
28762884

0 commit comments

Comments
 (0)