Skip to content

Conversation

@RonnyPfannschmidt
Copy link
Member

Summary

  • Introduce class hierarchies for hook callers (_NormalHookCaller, _FirstResultHookCaller, _HistoricHookCaller) and implementations (_NormalHookImplementation, _NewStyleWrapper, _OldStyleWrapper)
  • Each implementation type knows how to call itself or setup/teardown its wrapper
  • The core _multicall loop becomes trivially simple:
    for wrapper in reversed(wrapper_impls):
        teardowns.append(wrapper.setup_teardown(caller_kwargs))
    for impl in reversed(normal_impls):
        res = impl.call(caller_kwargs)
    for teardown in reversed(teardowns):
        outcome, exception = teardown(outcome, exception)

Test plan

  • All 124 tests pass
  • Pre-commit checks pass

🤖 Generated with Claude Code

RonnyPfannschmidt and others added 3 commits November 29, 2025 11:37
…ntations

Divide hook abstractions into specialized types that encode behavior through
class identity rather than runtime flags. This enables type-based dispatch
via match statements instead of conditional branching on attributes.

Hook callers now specialize by result handling strategy (list, first-result,
historic). Hook implementations specialize by execution style (normal vs
wrapper, new vs legacy wrapper). The _multicall function receives separate
lists for normal and wrapper implementations, enabling cleaner dispatch logic.

Backward compatibility maintained via HookCaller alias and legacy HookImpl.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Shift responsibility for argument extraction and wrapper
setup/teardown from _multicall into the hook implementation
classes themselves. The hookexec loop is now a simple iteration:

- setup_teardown() on each wrapper (returns teardown callable)
- call() on each normal impl
- teardown(result, exception) returns (result, exception)

Key changes:
- Add _get_args() method to base _HookImplementation
- Add call() method to _NormalHookImplementation
- Add setup_teardown() method to _WrapperHookImplementation
- Teardown returns tuple instead of raising exceptions
- Result objects only created for legacy hookwrappers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update test_hook_and_wrappers_speed to use separate normal_impls
and wrapper_impls lists with _create_hook_implementation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant