Conversation
msullivan
force-pushed
the
ast-versions
branch
from
October 1, 2026 22:17
9c76caa to
2c42245
Compare
Cond, UnpackMap, GetAssociated to represent our syntax_Cond, _UnpackMap, _GetAssociated to represent our syntax
Collaborator
Author
|
Oh, an advantage of the lambda syntax would be that it would mirror the Python scoping behavior of a comprehension better, which maybe we want. |
The plan here is that we will start moving to an AST-first setup (based on eventually PEP 849) in which we get an AST and translate that into `typing` objects. Currently, UnpackMap is set up like: `UnpackMap[Body, T, Target]` is equivalent to `*[Body for T in Iter[Target]]`, and `T` needs to be an already declared `TypeVar`. (An optional 4th argument allows putting an `if`.) An alternative would be to have it be `UnpackMap[Body, lambda T: Target]`. Thoughts? That's already kind of how we write `GenericCallable`, though I'm not sure that `GenericCallable` is really done in an acceptable way right now...
msullivan
force-pushed
the
ast-versions
branch
from
October 3, 2026 00:51
2c42245 to
6e5de77
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The plan here is that we will start moving to an AST-first setup
(based on eventually PEP 849) in which we get an AST and translate
that into
typingobjects.Currently, _UnpackMap is set up like:
_UnpackMap[Target, T, Body]is equivalent to*[Body for T in Iter[Target]], andTneeds to bean already declared
TypeVar.(An optional 4th argument allows putting an
if.)An alternative would be to have it be
_UnpackMap[Target, lambda T: Body].Thoughts? That's already kind of how we write
GenericCallable,though I'm not sure that
GenericCallableis really done in anacceptable way right now...
All add versions for all the boolean operations,
_And,_All, etc.I think my idea is that they will be semi-stable APIs, like a lot of the existing
typing stuff: they get used by introspection code but aren't really public APIs.
Originally I had planned for them to be non-underscore-prefixed public APIs,
and we could still do that if we wanted (for backporting without needing to
do any shenanigans?). Part of why I moved away from that was realizing
that we also have all the boolean operators, so there would kind of be a lot of them.