-
Notifications
You must be signed in to change notification settings - Fork 898
python 3.6 variable annotation #500
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
Comments
We should support it. But you might need to run yapf with Python 3.6+ to enable it. I looked at the link. Are there specific examples that were being messed up? |
Right now, I need to write something like this snippet taken from my code:
If Python 3.6 variable annotations were supported, I could write this:
The variable annotation is needed for mypy, which can't infer the type of an empty list. Another example is this (which is a workaround for mypy issue 4547:
which I'd like to write:
|
@gwelymernans Is this the kind of thing that I could fix by myself, if you point me at the appropriate place(s) in yapf? |
Python 3.7 dataclasses require the use of variable annotations, so it would be really nice if variable annotatios could be supported by yapf. |
I'm not familiar with this new syntax, but from briefly looking at the grammar we would need to add |
The new syntax is essentially the same as the parameter:type=default syntax in "def" statements. Probably it can be processed the same way. lib2to3/Grammar.txt has some changes between 3.6 and 3.7 (besides the one change you've already handled), so I'm surprised that yapf even works without handling the other grammar changes. If it helps, I can go back through some of my changelists to find out what changes I've needed to handle the changes between 3.6 and 3.7. |
I would like to help with this Issue, but I am unfamiliar with the codebase. Is there any way I may contribute? |
Python 3.6 allows variable annotation, but yapf doesn't support it. e.g.:
The text was updated successfully, but these errors were encountered: