start cleaning up the ast/interpreter.py type mess - #15933
Open
bonzini wants to merge 13 commits into
Open
Conversation
11 tasks
bonzini
force-pushed
the
type-ivar
branch
2 times, most recently
from
June 19, 2026 11:21
dc0afdf to
85c7355
Compare
bonzini
marked this pull request as ready for review
June 19, 2026 12:11
bonzini
force-pushed
the
type-ivar
branch
2 times, most recently
from
July 25, 2026 06:30
02f6952 to
2f927c9
Compare
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
These are now guaranteed by typing annotations. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
dnicolodi
reviewed
Aug 18, 2026
dnicolodi
reviewed
Aug 18, 2026
While the typing annotations in ast/interpreter.py are a mess, the calls to reduce_arguments() are all from evaluate_* functions. These have no usage of Any or casts that could obscure the type of the argument, so there is no way that the args argument is a list instead of an ArgumentNode. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Follow what is specified by TYPE_method_func. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Remove unused argument as well as the non-list case. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
The return type of flatten_args can actually be described more precisely than T.Any, but in some cases it is used to operate on variables described as T.List[TYPE_var] specifically and erroneously (because they can be Unknownvalue, etc.). Call those out specifically. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Introspection* objects and dictionaries can be handled without doing anything. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This also enables using it instead of flatten(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
dnicolodi
reviewed
Aug 18, 2026
dnicolodi
reviewed
Aug 18, 2026
The return value of "and" and "or" might be known even if one of the operands is unknown. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
reduce_arguments and flatten_args operate on values that are TYPE_var | mparser.BaseNode | some other types, but this is hidden behind Any. Introduce TYPE_ivar and TYPE_ikwargs to make the representation a bit closer to the truth. Of course, because this replaces Any, a lot of casts and "type: ignore" comments are needed. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Contributor
Author
|
@dcbaker this seems good to go after a bit more testing and Daniele's review. It adds a lot of casts and the typing is far from correct, but at least it gets rid of Any. Let me know if you think it's an improvement at all... |
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.
Commit "ast/interpreter, rewriter: make flatten_args() recursive" is the really scary one. Apart from that it's mostly dead code removal that enables more reasoning on what's going on.