You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 05571b1
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: test-data/unit/check-abstract.test
+14-4Lines changed: 14 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -311,7 +311,9 @@ class A(metaclass=ABCMeta):
311
311
def g(self, x: int) -> int: pass
312
312
class B(A):
313
313
def f(self, x: str) -> int: \
314
-
# E: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "int"
314
+
# E: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "int" \
315
+
# N: This violates the Liskov substitution principle \
316
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
315
317
pass
316
318
def g(self, x: int) -> int: pass
317
319
[out]
@@ -327,7 +329,9 @@ class J(metaclass=ABCMeta):
327
329
def g(self, x: str) -> str: pass
328
330
class A(I, J):
329
331
def f(self, x: str) -> int: pass \
330
-
# E: Argument 1 of "f" is incompatible with supertype "I"; supertype defines the argument type as "int"
332
+
# E: Argument 1 of "f" is incompatible with supertype "I"; supertype defines the argument type as "int" \
333
+
# N: This violates the Liskov substitution principle \
334
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
331
335
def g(self, x: str) -> int: pass \
332
336
# E: Return type "int" of "g" incompatible with return type "str" in supertype "J"
333
337
def h(self) -> int: pass # Not related to any base class
@@ -342,7 +346,9 @@ class J(metaclass=ABCMeta):
342
346
class I(J): pass
343
347
class A(I):
344
348
def f(self, x: str) -> int: pass \
345
-
# E: Argument 1 of "f" is incompatible with supertype "J"; supertype defines the argument type as "int"
349
+
# E: Argument 1 of "f" is incompatible with supertype "J"; supertype defines the argument type as "int" \
350
+
# N: This violates the Liskov substitution principle \
351
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
346
352
[out]
347
353
348
354
[case testInvalidOverridingAbstractMethod]
@@ -353,7 +359,9 @@ class J(metaclass=ABCMeta):
353
359
def f(self, x: 'J') -> None: pass
354
360
class I(J):
355
361
@abstractmethod
356
-
def f(self, x: 'I') -> None: pass # E: Argument 1 of "f" is incompatible with supertype "J"; supertype defines the argument type as "J"
362
+
def f(self, x: 'I') -> None: pass # E: Argument 1 of "f" is incompatible with supertype "J"; supertype defines the argument type as "J" \
363
+
# N: This violates the Liskov substitution principle \
364
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
357
365
[out]
358
366
359
367
[case testAbstractClassCoAndContraVariance]
@@ -375,6 +383,8 @@ class A(I):
375
383
pass
376
384
[out]
377
385
main:11: error: Argument 1 of "h" is incompatible with supertype "I"; supertype defines the argument type as "I"
386
+
main:11: note: This violates the Liskov substitution principle
387
+
main:11: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
378
388
main:11: error: Return type "I" of "h" incompatible with return type "A" in supertype "I"
Copy file name to clipboardExpand all lines: test-data/unit/check-classes.test
+20-4Lines changed: 20 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -282,6 +282,8 @@ class B(A):
282
282
def h(self, x: A, y: 'B') -> object: pass # Fail
283
283
[out]
284
284
main:7: error: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "A"
285
+
main:7: note: This violates the Liskov substitution principle
286
+
main:7: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
285
287
main:9: error: Return type "object" of "h" incompatible with return type "A" in supertype "A"
286
288
287
289
[case testEqMethodsOverridingWithNonObjects]
@@ -290,6 +292,8 @@ class A:
290
292
[builtins fixtures/attr.pyi]
291
293
[out]
292
294
main:2: error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
295
+
main:2: note: This violates the Liskov substitution principle
296
+
main:2: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
293
297
main:2: note: It is recommended for "__eq__" to work with arbitrary objects, for example:
@@ -318,6 +322,8 @@ class C(B): # with gap in implementations
318
322
pass
319
323
[out]
320
324
main:6: error: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "B"
325
+
main:6: note: This violates the Liskov substitution principle
326
+
main:6: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
def g(x: str, y: str) -> None: pass # E: Argument 1 of "g" is incompatible with supertype "A"; supertype defines the argument type as "int"
468
+
def g(x: str, y: str) -> None: pass # E: Argument 1 of "g" is incompatible with supertype "A"; supertype defines the argument type as "int" \
469
+
# N: This violates the Liskov substitution principle \
470
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
463
471
[builtins fixtures/classmethod.pyi]
464
472
465
473
[case testOverrideClassMethodWithClassMethod]
@@ -473,7 +481,9 @@ class B(A):
473
481
@classmethod
474
482
def f(cls, x: int, y: str) -> None: pass
475
483
@classmethod
476
-
def g(cls, x: str, y: str) -> None: pass # E: Argument 1 of "g" is incompatible with supertype "A"; supertype defines the argument type as "int"
484
+
def g(cls, x: str, y: str) -> None: pass # E: Argument 1 of "g" is incompatible with supertype "A"; supertype defines the argument type as "int" \
485
+
# N: This violates the Liskov substitution principle \
486
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
477
487
[builtins fixtures/classmethod.pyi]
478
488
479
489
[case testOverrideClassMethodWithStaticMethod]
@@ -489,7 +499,9 @@ class B(A):
489
499
@staticmethod
490
500
def f(x: int) -> None: pass
491
501
@staticmethod
492
-
def g(x: str) -> int: pass # E: Argument 1 of "g" is incompatible with supertype "A"; supertype defines the argument type as "int"
502
+
def g(x: str) -> int: pass # E: Argument 1 of "g" is incompatible with supertype "A"; supertype defines the argument type as "int" \
503
+
# N: This violates the Liskov substitution principle \
504
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
493
505
@staticmethod
494
506
def h() -> int: pass
495
507
[builtins fixtures/classmethod.pyi]
@@ -507,7 +519,9 @@ class B(A):
507
519
@classmethod
508
520
def f(cls, x: int) -> None: pass
509
521
@classmethod
510
-
def g(cls, x: int) -> int: pass # E: Argument 1 of "g" is incompatible with supertype "A"; supertype defines the argument type as "str"
522
+
def g(cls, x: int) -> int: pass # E: Argument 1 of "g" is incompatible with supertype "A"; supertype defines the argument type as "str" \
523
+
# N: This violates the Liskov substitution principle \
524
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
511
525
@classmethod
512
526
def h(cls) -> int: pass
513
527
[builtins fixtures/classmethod.pyi]
@@ -2478,6 +2492,8 @@ class D(A):
2478
2492
[out]
2479
2493
main:6: error: Return type "A" of "__iadd__" incompatible with return type "B" in "__add__" of supertype "A"
2480
2494
main:8: error: Argument 1 of "__iadd__" is incompatible with "__add__" of supertype "A"; supertype defines the argument type as "A"
2495
+
main:8: note: This violates the Liskov substitution principle
2496
+
main:8: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
2481
2497
main:8: error: Signatures of "__iadd__" and "__add__" are incompatible
Copy file name to clipboardExpand all lines: test-data/unit/check-columns.test
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -262,7 +262,9 @@ if int():
262
262
class A:
263
263
def f(self, x: int) -> None: pass
264
264
class B(A):
265
-
def f(self, x: str) -> None: pass # E:5: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "int"
265
+
def f(self, x: str) -> None: pass # E:5: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "int" \
266
+
# N:5: This violates the Liskov substitution principle \
267
+
# N:5: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
266
268
class C(A):
267
269
def f(self, x: int) -> int: pass # E:5: Return type "int" of "f" incompatible with return type "None" in supertype "A"
Copy file name to clipboardExpand all lines: test-data/unit/check-dynamic-typing.test
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -704,7 +704,9 @@ class C:
704
704
class B(C):
705
705
def f(self, a): pass
706
706
class A(B):
707
-
def f(self, a: 'D') -> None: # E: Argument 1 of "f" is incompatible with supertype "C"; supertype defines the argument type as "A"
707
+
def f(self, a: 'D') -> None: # E: Argument 1 of "f" is incompatible with supertype "C"; supertype defines the argument type as "A" \
708
+
# N: This violates the Liskov substitution principle \
709
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
Copy file name to clipboardExpand all lines: test-data/unit/check-errorcodes.test
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -279,7 +279,9 @@ class D:
279
279
def f(self, x: int) -> int:
280
280
return 0
281
281
class E(D):
282
-
def f(self, x: str) -> int: # E: Argument 1 of "f" is incompatible with supertype "D"; supertype defines the argument type as "int" [override]
282
+
def f(self, x: str) -> int: # E: Argument 1 of "f" is incompatible with supertype "D"; supertype defines the argument type as "int" [override] \
283
+
# N: This violates the Liskov substitution principle \
284
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
Copy file name to clipboardExpand all lines: test-data/unit/check-functions.test
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,10 @@ class A(object):
46
46
def f(self, a: int, b: str) -> None: pass
47
47
48
48
class B(A):
49
-
def f(self, b: str, a: int) -> None: pass # E: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "int" # E: Argument 2 of "f" is incompatible with supertype "A"; supertype defines the argument type as "str"
49
+
def f(self, b: str, a: int) -> None: pass # E: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "int" \
50
+
# N: This violates the Liskov substitution principle \
51
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides \
52
+
# E: Argument 2 of "f" is incompatible with supertype "A"; supertype defines the argument type as "str"
Copy file name to clipboardExpand all lines: test-data/unit/check-generic-subtyping.test
+23-7Lines changed: 23 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -189,7 +189,9 @@ class C: pass
189
189
class D: pass
190
190
class A(B[C]):
191
191
def f(self, a: D) -> None: pass \
192
-
# E: Argument 1 of "f" is incompatible with supertype "B"; supertype defines the argument type as "C"
192
+
# E: Argument 1 of "f" is incompatible with supertype "B"; supertype defines the argument type as "C" \
193
+
# N: This violates the Liskov substitution principle \
194
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
193
195
def g(self, a: C) -> None: pass
194
196
[out]
195
197
@@ -202,7 +204,9 @@ class B:
202
204
def g(self, a: C) -> None: pass
203
205
class A(B, Generic[T]):
204
206
def f(self, a: T) -> None: pass \
205
-
# E: Argument 1 of "f" is incompatible with supertype "B"; supertype defines the argument type as "C"
207
+
# E: Argument 1 of "f" is incompatible with supertype "B"; supertype defines the argument type as "C" \
208
+
# N: This violates the Liskov substitution principle \
209
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
206
210
def g(self, a: 'C') -> None: pass
207
211
[out]
208
212
@@ -215,7 +219,9 @@ class B(Generic[T]):
215
219
def g(self, a: T) -> None: pass
216
220
class A(B[S], Generic[T, S]):
217
221
def f(self, a: T) -> None: pass \
218
-
# E: Argument 1 of "f" is incompatible with supertype "B"; supertype defines the argument type as "S"
222
+
# E: Argument 1 of "f" is incompatible with supertype "B"; supertype defines the argument type as "S" \
223
+
# N: This violates the Liskov substitution principle \
224
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
219
225
def g(self, a: S) -> None: pass
220
226
[out]
221
227
@@ -233,7 +239,9 @@ class C(Generic[T, U, V]):
233
239
class B(C[D, D, T], Generic[T]): pass
234
240
class A(B[S], Generic[T, S]):
235
241
def f(self, a: T) -> None: pass \
236
-
# E: Argument 1 of "f" is incompatible with supertype "C"; supertype defines the argument type as "S"
242
+
# E: Argument 1 of "f" is incompatible with supertype "C"; supertype defines the argument type as "S" \
243
+
# N: This violates the Liskov substitution principle \
244
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
237
245
def g(self, a: S) -> None: pass
238
246
[out]
239
247
@@ -283,6 +291,8 @@ class D(A):
283
291
def f(self, x: T1, y: S) -> None: pass # TODO: This error could be more specific.
284
292
[out]
285
293
main:12: error: Argument 2 of "f" is incompatible with supertype "A"; supertype defines the argument type as "S"
294
+
main:12: note: This violates the Liskov substitution principle
295
+
main:12: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
286
296
main:14: error: Signature of "f" incompatible with supertype "A"
287
297
288
298
@@ -538,7 +548,9 @@ class I(Generic[T]):
538
548
def g(self, a: T) -> None: pass
539
549
class A(I[C]):
540
550
def f(self, a: 'D') -> None: pass \
541
-
# E: Argument 1 of "f" is incompatible with supertype "I"; supertype defines the argument type as "C"
551
+
# E: Argument 1 of "f" is incompatible with supertype "I"; supertype defines the argument type as "C" \
552
+
# N: This violates the Liskov substitution principle \
553
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
542
554
def g(self, a: 'C') -> None: pass
543
555
class C: pass
544
556
class D: pass
@@ -570,7 +582,9 @@ class B(I[C]):
570
582
def g(self, a: 'C', b: Any) -> None: pass
571
583
class A(B):
572
584
def g(self, a: 'C', b: 'C') -> None: pass \
573
-
# E: Argument 2 of "g" is incompatible with supertype "I"; supertype defines the argument type as "D"
585
+
# E: Argument 2 of "g" is incompatible with supertype "I"; supertype defines the argument type as "D" \
586
+
# N: This violates the Liskov substitution principle \
587
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
574
588
def f(self, a: 'C', b: 'C') -> None: pass
575
589
class C: pass
576
590
class D: pass
@@ -587,7 +601,9 @@ class B(I[C]):
587
601
def f(self, a: 'C', b: Any) -> None: pass
588
602
class A(B):
589
603
def f(self, a: 'C', b: 'D') -> None: pass \
590
-
# E: Argument 2 of "f" is incompatible with supertype "I"; supertype defines the argument type as "C"
604
+
# E: Argument 2 of "f" is incompatible with supertype "I"; supertype defines the argument type as "C" \
605
+
# N: This violates the Liskov substitution principle \
606
+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
Copy file name to clipboardExpand all lines: test-data/unit/check-multiple-inheritance.test
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -539,6 +539,8 @@ class IntFlag(int, Flag):
539
539
def __or__(self: _T, other: str) -> _T: ...
540
540
[out]
541
541
main:8: error: Argument 1 of "__or__" is incompatible with supertype "Flag"; supertype defines the argument type as "IntFlag"
542
+
main:8: note: This violates the Liskov substitution principle
543
+
main:8: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
0 commit comments