Skip to content

Use lambda in GenericCallable.#77

Merged
dnwpark merged 5 commits intomainfrom
generic-callable
Feb 6, 2026
Merged

Use lambda in GenericCallable.#77
dnwpark merged 5 commits intomainfrom
generic-callable

Conversation

@dnwpark
Copy link
Contributor

@dnwpark dnwpark commented Feb 4, 2026

GenericCallable should now be used like GenericCallable[tuple[T, U], lambda T, U: Callable[[T, U], tuple[T, U]]]

The __class_getitem__ method is used to generate a _GenericCallableGenericAlias.

@vercel
Copy link

vercel bot commented Feb 4, 2026

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

Project Deployment Actions Updated (UTC)
python-typemap Ready Ready Preview, Comment Feb 4, 2026 5:57pm

@dnwpark dnwpark requested a review from msullivan February 4, 2026 17:57
Comment on lines 589 to +593
if root.__type_params__:
f = GenericCallable[tuple[*root.__type_params__], f]
# Must store a lambda that performs type variable substitution
type_params = root.__type_params__
callable_lambda = _create_generic_callable_lambda(f, type_params)
f = GenericCallable[tuple[*type_params], callable_lambda]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for this to work right in the cases where the annotations do nontrivial computation on the params, it needs to go first, and then the whole rest of everything needs to be in the lambda?

Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works and I think maintains parity with what we have now, but it'll need a bit of restructuring to fully solve the problems we want to solve with it

@dnwpark dnwpark merged commit 7a90bd1 into main Feb 6, 2026
5 checks passed
@dnwpark dnwpark deleted the generic-callable branch February 6, 2026 01:13
dnwpark added a commit that referenced this pull request Feb 6, 2026
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.

2 participants