-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add coding style recommendations for variable annotations #548
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
Conversation
pep-0008.txt
Outdated
class Test: | ||
result: int=0 # No spaces around equality sign | ||
|
||
- Although the PEP 526 is accepted for Python 3.6, the variabe annotation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "variable" (and "preferred" on the next line)
pep-0008.txt
Outdated
similar to those on function annotations described above: | ||
|
||
- Annotations for module level variables, class and instance variables, | ||
and local variables should have a single space after corresponding colon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd replace "corresponding" with "the".
@JelleZijlstra Thanks! Fixed. |
cc @gvanrossum (just in case you aren't watching peps). |
- If an assignment has a right hand side, then the equality sign should have | ||
exactly one space on both sides. | ||
|
||
- Yes:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this style, but currently PEP 8 isn't explicit about function annotations styles (I could be missing it). Rather than refer back to PEP 484 - which is large and covers many topics - maybe PEP 8 should be more explicit and prescriptive about both function and variable annotations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually PEP 8 has a small section on function annotations already: https://www.python.org/dev/peps/pep-0008/#function-annotations
Great! |
@gvanrossum It does, but I guess I'd like some examples. :) No worries, we can handle that under a separate PR. |
Fixes #543
As discussed in python/typeshed#1803 I update three PEPs: 8, 484, and 526
with the relevant discussion about the coding style for variable annotations and their preferred use in stub files.