This repository was archived by the owner on Sep 14, 2020. It is now read-only.
Resolve a terminology conflict: event-watching vs state-changing causes #202
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.
Fix the terminology mess between the event-watching and state-changing causes & reactions.
Description
Since the event-handlers were introduced, there was a terminology chaos in the framework. Specifically, the "event-handling" routines had different signatures than the "cause-handling" routines, despite doing exactly the same, in almost the same way. This became very obvious during the throughout type annotation in #200.
This PR changes the internal terminology both for causation and for handling of such different causes:
Internally, the causes are also converted to a more suitable data structures: dataclasses (Python 3.7+). This allows their inheritance, unlike with the namedtuples.
The legacy methods and properties are left in place for backward-compatibility of semi-public interfaces: the registries were exposed to the users, so they could be used; but these specific methods were not documented and were used mostly internally (but this cannot be guaranteed).
Actual purpose: This PR is extracted from the following PR with the auto-guessed implicit owners for hierarchy building: it will require identifying the current object in a similar way in all kind of handlers, regardless of their nature -- hence, they all should have a "cause" with the same core properties.
Types of Changes
There are no behaviour changes in theory. In practice, some semi-public methods could be broken: they are untested, but they are also not supposed to be used externally, and are not used internally.