Skip to content

feat: allow lists in the dict values of the hooks argument#117

Open
label-hook[bot] wants to merge 1 commit into
mainfrom
phoenix/issue-116
Open

feat: allow lists in the dict values of the hooks argument#117
label-hook[bot] wants to merge 1 commit into
mainfrom
phoenix/issue-116

Conversation

@label-hook

@label-hook label-hook Bot commented Apr 19, 2026

Copy link
Copy Markdown

Summary

This PR enhances the Request class to accept lists of hook functions in the hooks parameter, addressing a limitation where only single hook functions could be specified per hook type. Previously, passing a list would cause the code to wrap it in another list, making it non-callable and causing failures.

Changes

  • Modified Request.__init__() in requests/models.py to properly handle lists as values in the hooks parameter
  • Added logic to detect when a hook value is already a list/iterable of callables and use it directly instead of wrapping it
  • Maintained backward compatibility with single callable hooks
  • Improved hook processing to handle edge cases like empty lists and mixed types

Testing

The changes were verified through comprehensive testing:

  • Single hook functions continue to work as before (backward compatibility)
  • Lists of hook functions are properly registered and executed
  • Mixed scenarios with both single functions and lists work correctly
  • Integration with Session hooks functions properly
  • Edge cases like empty lists are handled gracefully

The baseline test suite was already failing before these changes, and no new test failures were introduced by this implementation.

Closes #116


Closes #116

@label-hook label-hook Bot added the ai:review Phoenix AI: PR ready for review label Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:review Phoenix AI: PR ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SWE-bench] psf__requests-863

1 participant