Skip to content

Wrap extended callable params in a Params type#110

Merged
msullivan merged 6 commits intomainfrom
params
Mar 18, 2026
Merged

Wrap extended callable params in a Params type#110
msullivan merged 6 commits intomainfrom
params

Conversation

@msullivan
Copy link
Collaborator

The type serves as a quasi-bound on ParamSpec.

See python/peps#4866

@msullivan msullivan requested a review from dnwpark March 18, 2026 20:47
@vercel
Copy link

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
python-typemap Ready Ready Preview, Comment Mar 18, 2026 9:27pm

Introduce Params[*Ps] as a wrapper for the parameter list in extended
Callable types. Callable[Params[Param[...], ...], ret] replaces
Callable[[Param[...], ...], ret], making it easy to distinguish
extended callables from standard ones. GetArg on a Callable now
always returns Params[...] for the first arg.

Uses typing._ConcatenateGenericAlias internally so that Params
survives the typing.Callable round-trip without monkey-patching.
_callable_type_to_signature now treats standard callables
(Callable[[type, ...], ret]) separately from extended callables
(Callable[Params[Param[...], ...], ret]). All test files updated
to use Params wrapper consistently.
Callable[[Param[...], ...], ret] now raises TypeError instead of
silently producing wrong results. Must use Callable[Params[...], ret].
Extract _unwrap_params helper that handles Params[...], list, and
tuple[...] uniformly for all three callable kinds (Callable,
classmethod, staticmethod). Standard callables produce simple
positional-only signatures; Param types without Params wrapper
are rejected.
Ellipsis in Callable[..., ret] and bare Callable now produce
Params[Param[None, Any, "*"], Param[None, Any, "**"]] instead
of SpecialFormEllipsis, so all Callable param access consistently
returns Params.
@msullivan msullivan merged commit 6571c74 into main Mar 18, 2026
5 checks passed
@msullivan msullivan deleted the params branch March 18, 2026 22:14
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