@@ -1136,13 +1136,15 @@ def signature_incompatible_with_supertype(
1136
1136
name_in_super : str ,
1137
1137
supertype : str ,
1138
1138
context : Context ,
1139
- original : FunctionLike | None = None ,
1140
- override : FunctionLike | None = None ,
1139
+ original : ProperType ,
1140
+ override : ProperType ,
1141
1141
) -> None :
1142
1142
code = codes .OVERRIDE
1143
1143
target = self .override_target (name , name_in_super , supertype )
1144
1144
self .fail (f'Signature of "{ name } " incompatible with { target } ' , context , code = code )
1145
1145
1146
+ original_str , override_str = format_type_distinctly (original , override , options = self .options , bare = True )
1147
+
1146
1148
INCLUDE_DECORATOR = True # Include @classmethod and @staticmethod decorators, if any
1147
1149
ALLOW_DUPS = True # Allow duplicate notes, needed when signatures are duplicates
1148
1150
ALIGN_OFFSET = 1 # One space, to account for the difference between error and note
@@ -1152,13 +1154,8 @@ def signature_incompatible_with_supertype(
1152
1154
# note: def f(self) -> str
1153
1155
# note: Subclass:
1154
1156
# note: def f(self, x: str) -> None
1155
- if (
1156
- original is not None
1157
- and isinstance (original , (CallableType , Overloaded ))
1158
- and override is not None
1159
- and isinstance (override , (CallableType , Overloaded ))
1160
- ):
1161
- self .note ("Superclass:" , context , offset = ALIGN_OFFSET + OFFSET , code = code )
1157
+ self .note ("Superclass:" , context , offset = ALIGN_OFFSET + OFFSET , code = code )
1158
+ if isinstance (original , (CallableType , Overloaded )):
1162
1159
self .pretty_callable_or_overload (
1163
1160
original ,
1164
1161
context ,
@@ -1167,8 +1164,16 @@ def signature_incompatible_with_supertype(
1167
1164
allow_dups = ALLOW_DUPS ,
1168
1165
code = code ,
1169
1166
)
1167
+ else :
1168
+ self .note (
1169
+ original_str ,
1170
+ context ,
1171
+ offset = ALIGN_OFFSET + 2 * OFFSET ,
1172
+ code = code ,
1173
+ )
1170
1174
1171
- self .note ("Subclass:" , context , offset = ALIGN_OFFSET + OFFSET , code = code )
1175
+ self .note ("Subclass:" , context , offset = ALIGN_OFFSET + OFFSET , code = code )
1176
+ if isinstance (override , (CallableType , Overloaded )):
1172
1177
self .pretty_callable_or_overload (
1173
1178
override ,
1174
1179
context ,
@@ -1177,6 +1182,13 @@ def signature_incompatible_with_supertype(
1177
1182
allow_dups = ALLOW_DUPS ,
1178
1183
code = code ,
1179
1184
)
1185
+ else :
1186
+ self .note (
1187
+ override_str ,
1188
+ context ,
1189
+ offset = ALIGN_OFFSET + 2 * OFFSET ,
1190
+ code = code ,
1191
+ )
1180
1192
1181
1193
def pretty_callable_or_overload (
1182
1194
self ,
0 commit comments