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.
Api-Change for: Before/After Events
This PR changes the way
before_eventname
/after_eventname
events communicate with their caller (namely the event with the according nameeventname
.Attention: This is a breaking change.
Reason for this change is that these kinds of events could not switch position (change execution from before to after or vice versa) and could not be used as a standalone without changing the function signatures. This PR solves this issue by improving the API of these events.
API-Proposal:
before_
/after_
event gets called with a unique event object, that behaves just like the normal event object..hook
before_
-events can read and manipulate the function call arguments before the actual event will be called usingevent.hook["args"]
andevent.hook["kwargs"]
after_
-events can read the function call arguments after the actual event has been called with (including the changes of potentialbefore_
-hooks usingevent.hook["args"]
andevent.hook["kwargs"]
(Note: Any modification will only change the arguments for future
after_
-events but not for the function call itself.)after_
-events can additionally alternate the return value of the event by modifyingevent.hook["result"]
.event.hook["name"]
Example Module:
Running this module should result in the following output: