-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tested and documented undefined inheritance #296
Tested and documented undefined inheritance #296
Conversation
If the base class does not inherit from ``DBC`` or uses ``DBCMeta`` as the meta class, inheritance of invariants will be broken. In this patch, we tested and documented this unexpected behavior to warn the users about this important footgun. Fixes #295.
Looks like it wouldn't be hard to check this at runtime. For example, after this line there could be a check like |
Can you please clarify a bit? Note that the check: icontract/icontract/_decorators.py Line 478 in 625e797
is just making sure that there was no bug in the implementation. That is, that all the runtime types are as expected. |
When Maybe it's also possible to copy the list every time, as in |
@verinov thanks for the clarifications! I looked into this for some time. After quite some experiments, I decided to leave it at the documentation. Namely, the Liskov substitution principle would be broken without the inheritance from DBC or setting DBCMeta as a meta class for pre-conditions. I could always make the copy for invariants, postconditions and snapshots, but that would mask the error, and make the code of the library very messy and pretty unmaintainable. |
If the base class does not inherit from
DBC
or usesDBCMeta
as the meta class, inheritance of invariants will be broken.In this patch, we tested and documented this unexpected behavior to warn the users about this foot-gun.