PyCQA / PyCQA/pycodestyle

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

Open
#980 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.2k
Forks
754
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the three call examples from the issue with the current pycodestyle version, then trace the checker that handles trailing commas. Done means the intended trailing-comma cases are consistently flagged and regression coverage verifies the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.