Skip to content

Make all the type operations get interpreted only by the evaluator#9

Merged
msullivan merged 12 commits intomainfrom
register-eval
Nov 17, 2025
Merged

Make all the type operations get interpreted only by the evaluator#9
msullivan merged 12 commits intomainfrom
register-eval

Conversation

@msullivan
Copy link
Collaborator

@msullivan msullivan commented Nov 10, 2025

The hairy part here is the "syntactic" ones that
can't just be treated as functions: Iter and Is. My approach
was to have special types with overloaded __iter__ and __bool__
methods that will try to call a hook registered in a ContextVar,
and fall back to some default behavior if not set (Iter returns an
Unpack and Is returns false)

@msullivan msullivan requested a review from 1st1 November 10, 2025 22:11
@msullivan msullivan changed the title Make most of the type functions get interpreted only by the evaluator Make all the type operations get interpreted only by the evaluator Nov 12, 2025
Is will just return False, while _IterGenericAlias will return an
Unpack of some typevar.
This is kind of unprincipled though still
@msullivan msullivan merged commit 631ae34 into main Nov 17, 2025
1 check passed
@msullivan msullivan deleted the register-eval branch November 17, 2025 20:08
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