start cleaning up the ast/interpreter.py type mess#15933
Open
bonzini wants to merge 12 commits into
Open
Conversation
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
These are now guaranteed by typing annotations. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 tasks
While the typing annotations in ast/interpreter.py are a mess, the calls to reduce_arguments() are all from the tame evaluate_* functions. 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>
This also enables using it instead of flatten(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
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>
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.