Skip to content

Don't fail compose signature when last function has no signature - #649

Open
heykav wants to merge 1 commit into
pytoolz:masterfrom
heykav:fix-compose-signature-no-return-sig
Open

heykav wants to merge 1 commit into
pytoolz:masterfrom
heykav:fix-compose-signature-no-return-sig

Conversation

@heykav

@heykav heykav commented Oct 11, 2026

Copy link
Copy Markdown

inspect.signature(compose(max, f)) raises ValueError: no signature found for builtin max even though f has a perfectly good signature. Compose.__signature__ only uses the last function for the return annotation, so I wrapped that lookup in a try/except and fall back to no return annotation.

I added a test that uses max as the last function. It fails before the change and passes after, and the existing tests still pass.

Compose.__signature__ only needs the last function for the return annotation, but called inspect.signature on it unguarded. For builtins like max or set this raised ValueError, so inspect.signature(compose(max, f)) failed even though f has a normal signature. Fall back to no return annotation in that case.

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.

1 participant