Skip to content

Conversation

ilevkivskyi
Copy link
Member

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.

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
Copy link
Member

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.
Copy link
Member

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".

@ilevkivskyi
Copy link
Member Author

@JelleZijlstra Thanks! Fixed.

@ilevkivskyi
Copy link
Member Author

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::
Copy link
Member

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?

Copy link
Member

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

@gvanrossum gvanrossum merged commit a81f56f into python:master Jan 19, 2018
@gvanrossum gvanrossum deleted the pep-8-for-pep-526 branch January 19, 2018 03:33
@gvanrossum
Copy link
Member

Great!

@warsaw
Copy link
Member

warsaw commented Jan 19, 2018

@gvanrossum It does, but I guess I'd like some examples. :) No worries, we can handle that under a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants