-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Is there an API to annotate the ast #4713
Comments
Such a feature currently does not exist. But you can insert |
Do we want to make this issue a feature request? There was an attempt before to do something similar in #2444, and I think it would be a nice thing to do. (Also I don't think there is another relevant issue open). |
Something like this would potentially be useful, but we can't make any progress with this until we have an understanding of the use cases where this could be helpful. The specifics of use cases could have a major impact on implementation details (and complexity of implementation). Here are some potential use cases I can think of (some of them are probably unrealistic, but including them here for completeness):
|
The other important use case is refactorings. Also note that And that in unannotated functions |
On 5 April 2018 at 11:45, Sebastian Kreft ***@***.***> wrote:
The other important use case is refactorings.
Also note that reveal_type cannot be used everywhere, for example it
cannot be used inside a comprehension.
And that in unannotated functions reveal_type just returns Any (with the
message note: 'reveal_type' always outputs 'Any' in unchecked functions).
For unannotated functions, perhaps pytype
<https://github.com/google/pytype> would be helpful? Unfortunately, it
doesn't annotate variables AFAIK, and when I last looked, its internal form
wasn't suitable for deeper analysis because it uses the bytecodes rather
than source code.
… —
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4713 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AhBmtc2RONSFXsI_ifaIYq89z9sqoP53ks5tlmY8gaJpZM4Sk9e9>
.
|
Mypy doesn't record inferred types in unannotated functions so this feature would not help with this. |
Let's close this issue, it's formulated as a question, and as a feature request it's too general. For a specific use case please file a fresh issue describing the use case in more detail. |
Is there an api to annotate the AST, I'm interested in knowing the type of all subexpressions.
For example in the code:
I would like to know that
and ideally the expression should have line number and offset information to match it with the AST nodes.
The text was updated successfully, but these errors were encountered: