Fix ground truth for inheritance/MRO benchmarks (Liskov substitution)#14
Open
jaltmayerpizzorno wants to merge 20 commits intosecure-software-engineering:mainfrom
Open
Conversation
…meration; - made test more interesting by substituting <value1> with more than just "int";
…able definition. Corresponds change a40d4db in the templates;
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! Thanks again for creating and maintaining TypeEvalPy — it's been an invaluable resource for our work evaluating type inference tools.
While running the benchmarks, we noticed that 5 inheritance/MRO ground truth annotations use only each method body's return type, without accounting for the Liskov substitution principle. When annotated as given,
mypy --strictreports incompatible override errors on all of them. Widening the parent method return types to include the subclass override types resolves this and makes the annotations consistent with what a type-safe program requires.Affected benchmarks
We verified with `mypy --strict` that the original annotations produce override errors and the corrected ones pass cleanly.
Thanks for considering this!