Skip to content

Commit da3f9ed

Browse files
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|str
1 parent 10ab41a commit da3f9ed

5 files changed

Lines changed: 10 additions & 3 deletions

File tree

micro-benchmark/python_features/classes/inheritance_overriding/main_gt.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"col_offset": 9,
66
"function": "MyClass.func",
77
"type": [
8+
"int",
89
"str"
910
]
1011
},

micro-benchmark/python_features/mro/parents_same_superclass/main_gt.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"col_offset": 9,
66
"function": "A.func",
77
"type": [
8+
"int",
89
"str"
910
]
1011
},

micro-benchmark/python_features/mro/self_assignment/main_gt.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"col_offset": 9,
2525
"function": "B.func",
2626
"type": [
27-
"int"
27+
"int",
28+
"str"
2829
]
2930
},
3031
{

micro-benchmark/python_features/mro/two_parents/main_gt.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"col_offset": 9,
1515
"function": "B.func",
1616
"type": [
17+
"int",
1718
"str"
1819
]
1920
},

micro-benchmark/python_features/mro/two_parents_method_defined/main_gt.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"col_offset": 9,
66
"function": "A.func",
77
"type": [
8-
"float"
8+
"float",
9+
"str"
910
]
1011
},
1112
{
@@ -14,7 +15,9 @@
1415
"col_offset": 9,
1516
"function": "B.func",
1617
"type": [
17-
"int"
18+
"float",
19+
"int",
20+
"str"
1821
]
1922
},
2023
{

0 commit comments

Comments
 (0)