Skip to content

Conversation

@mristin
Copy link
Collaborator

@mristin mristin commented Oct 27, 2025

Previously, we determined the invariants based on the self passed to the function. However, in case of super().__init__, the invariants that need to be checked after the call are those belonging to to the super class, not the current (child) class.

This change fixes the issue by passing in the class corresponding to the invariants alongside function and parameters, so that we can properly resolve which invariants need to be checked.

Fixes #300.

Previously, we determined the invariants based on the `self` passed to
the function. However, in case of `super().__init__`, the invariants
that need to be checked after the call are those belonging to to
the super class, not the current (child) class.

This change fixes the issue by passing in the class corresponding to
the invariants alongside function and parameters, so that we can
properly resolve which invariants need to be checked.

Fixes #300.
@mristin mristin force-pushed the mristin/Fix-invariant-of-subclass-applies-to-its-parent branch from 62616d1 to df646dc Compare October 28, 2025 15:28
@coveralls
Copy link

Coverage Status

coverage: 91.579% (+0.03%) from 91.548%
when pulling df646dc on mristin/Fix-invariant-of-subclass-applies-to-its-parent
into ecccd02 on master.

@mristin mristin merged commit 44fbab4 into master Oct 28, 2025
14 checks passed
@mristin mristin deleted the mristin/Fix-invariant-of-subclass-applies-to-its-parent branch October 28, 2025 15:35
mristin added a commit that referenced this pull request Nov 8, 2025
* Fix child invariants checked in ``super().__init__`` (#301)
* Support Python 3.13 (#309)
* Add support for Python 3.12 (#308)

This is a critical bugfix patch version. Previously, we determined
the invariants based on the ``self`` passed to the function. However,
in case of ``super().__init__``, the invariants that need to be checked
after the call are those belonging to to the super class, not
the current (child) class. This lead to erroneous invariant checks, where
the invariants of the child class where checked after the super-init call
in the parent class.
@mristin mristin mentioned this pull request Nov 8, 2025
mristin added a commit that referenced this pull request Nov 8, 2025
* Fix child invariants checked in ``super().__init__`` (#301)
* Support Python 3.13 (#309)
* Add support for Python 3.12 (#308)

This is a critical bugfix patch version. Previously, we determined
the invariants based on the ``self`` passed to the function. However,
in case of ``super().__init__``, the invariants that need to be checked
after the call are those belonging to to the super class, not
the current (child) class. This lead to erroneous invariant checks, where
the invariants of the child class where checked after the super-init call
in the parent class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invariants of the child class checked on super().__init__

3 participants