prettier/plugin-python

PEP 8 whitespace handling

taion opened this issue · 4 comments

taion commented

The whitespace handling in PEP 8 is a little different. Two cases stand out to me as unhandled.

Two spaces before inline comments

Current:

foo() # This is a comment.

Desired:

bar()  # This is a comment.

Two newlines between functions and classes at indent level 0

Current:

def foo():
    pass

def bar():
    pass

Desired:

def foo():
    pass


def bar():
    pass

One more: Missing whitespace at the end of single-item tuples:

Input (desired):

example = ("foo", )

Output:

example = ("foo",)

Edit: Nevermind, I remembered pep8 wrong.

Found another: missing spaces after commas in class parents:

Input (desired):

class MyClass(type1, type2):
	pass

Output:

class MyClass(type1,type2):
	pass
taion commented

PEP 8 explicitly enjoins against the space between the comma and the closing paren on single-element tuples: https://www.python.org/dev/peps/pep-0008/#pet-peeves

This is one of many inane YAPF-isms.

Huh, okay, never noticed that since flake8 doesn't complain about it. Nevermind that one then.