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.

Assessment

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

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.

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
Dominant language
Python
Stars
5.2k
Forks
765
Avg merge
1d 20h
Merged PRs (30d)
1

Getting set up

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.

More from PyCQA/pycodestyle

All issues in PyCQA/pycodestyle

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.