Skip to content

fix: support callable instances as guards and callbacks - #732

Open
Aschenbath wants to merge 1 commit into
fgmacedo:mainfrom
Aschenbath:fix/callable-instance-guards-731
Open

Aschenbath wants to merge 1 commit into
fgmacedo:mainfrom
Aschenbath:fix/callable-instance-guards-731

Conversation

@Aschenbath

Copy link
Copy Markdown

Fixes #731.

Callable objects used as guards currently fail during construction because callback registration and signature caching assume function metadata. Preserve the callable instance, inspect its original signature and partial bindings, and recognize asynchronous __call__ methods so false async guards are awaited and rejected correctly. Ordinary function and method binding keeps its existing path.

Add 21 regression cases covering direct/named guards, instance state, parameter injection, async engine selection, nested partials, explicit signatures, unhashable guards alongside nested callbacks, and callable actions. Document the supported forms with an executable example and release note.

Validation:

  • All 21 new cases fail on the unchanged base and pass from the installed wheel.
  • Full original pre-commit run passes, including mypy, pyright, Ruff and pytest; library coverage is 100% of 6,323 statements and 1,988 branches.
  • Sdist/wheel build and Twine checks pass. Sphinx builds; its 48 existing diagnostics exactly match the base.
  • An independent Codex reviewer found and verified fixes for nested partials and explicit signatures, then passed 12 additional behavior groups. The same probes pass on Python 3.12 and 3.14 against both source and installed wheel.

OpenAI Codex implemented and tested this change; a separate Codex agent reviewed it. No human review is claimed.

Signed-off-by: Nash Aschenbath <wwh86696@163.com>
@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

Support callable instances as transition guards or reject them clearly

1 participant