pycodestyle icon indicating copy to clipboard operation
pycodestyle copied to clipboard

E231: Check misses trailing comma in function or class calls that do not end with whitespace

Open lfiedler opened this issue 4 years ago • 5 comments

Trailing commas in function calls, e.g. print(1,2,) that do not end with a white space are not flagged by pycodestyle. From reading the corresponding PEP8 I would expect that pycodestyle would flag this.

Here's a small example:

def f(a, b):
    return a+b


class A:
    def __init__(self, a):
        self.a = a


if __name__ == "__main__":
    A(f(1, 2,),)
    print(f(1, 2,))
    print(1, 2,)

Although this is valid python code I'd expect pycodestyle to flag all of the three last lines, but it doesn't. Is this behaviour expected?

Environment:

  • Python 3.8.5
  • conda 4.9.2
  • pycodestyle 2.6.0

lfiedler avatar Feb 24 '21 12:02 lfiedler