Commit da3f9ed
committed
Fix ground truth for inheritance/MRO benchmarks (Liskov substitution)
The previous ground truth annotated each method with only its body's
return type, ignoring that subclass overrides must have compatible
return types per the Liskov substitution principle. When annotated as
given, mypy --strict reports override errors on every affected
benchmark. The corrected annotations widen parent method return types
to include subclass override types, making all benchmarks pass mypy.
Affected benchmarks:
- classes/inheritance_overriding: MyClass.func str -> int|str
- mro/parents_same_superclass: A.func str -> int|str
- mro/self_assignment: B.func int -> int|str
- mro/two_parents: B.func str -> int|str
- mro/two_parents_method_defined: A.func float -> float|str,
B.func int -> float|int|str1 parent 10ab41a commit da3f9ed
5 files changed
Lines changed: 10 additions & 3 deletions
File tree
- micro-benchmark/python_features
- classes/inheritance_overriding
- mro
- parents_same_superclass
- self_assignment
- two_parents_method_defined
- two_parents
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
0 commit comments