Skip to content

Commit c8c3d50

Browse files
committed
Merge branch 'disambiguate-if-needed' of https://github.com/eigengrau/mypy into eigengrau-disambiguate-if-needed
2 parents d7178c0 + 241a0d0 commit c8c3d50

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mypy/messages.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,14 @@ def incompatible_argument(self, n: int, m: int, callee: CallableType, arg_type:
417417
expected_type = callee.arg_types[m - 1]
418418
except IndexError: # Varargs callees
419419
expected_type = callee.arg_types[-1]
420+
arg_type_str = self.format(arg_type)
421+
expected_type_str = self.format(expected_type)
422+
# If type names turn out ambiguous, attempt to disambiguate.
423+
if arg_type_str == expected_type_str:
424+
arg_type_str = self.format(arg_type, verbose=True)
425+
expected_type_str = self.format(expected_type, verbose=True)
420426
msg = 'Argument {} {}has incompatible type {}; expected {}'.format(
421-
n, target, self.format(arg_type), self.format(expected_type))
427+
n, target, arg_type_str, expected_type_str)
422428
self.fail(msg, context)
423429

424430
def invalid_index_type(self, index_type: Type, base_str: str,

0 commit comments

Comments
 (0)