Detect unintended comma at the end of expression
See original GitHub issueI would be great to have a rule that will detect cases such this:
instance = MyClass(arg1, arg2),
As it is most likely a typo.
If someone wants a tuple, the preferred form would be (item,).
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Comma in f-string is detected as "Unexpected token at end of ...
No issues with the f-string. Actual behaviour. pylance detects an error in the f-string, next to the comma: "Unexpected token at end of...
Read more >Unintended comma matching in \d with Python regex
The \d is not matching the comma. The .+? is matching the first comma, because . matches any character, including a comma.
Read more >Comma operator (,) - JavaScript - MDN Web Docs
The comma ( , ) operator evaluates each of its operands (from left to right) and returns the value of the last operand....
Read more >Setting up specific expression to remove comma inside strings ...
I've tried splitting my CSV data along the double quotes (") and managed to isolate the values that have unwanted commas inside. As...
Read more >Best practices for using trailing commas in JavaScript
You can safely include a trailing comma after the last expression in an array like ... Be careful not to add more than...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m only worried about the additional overhead for just this one check. lib2to3 is in Python so it’s going to slow down Bugbear a bit. We can do it and measure how bad that slowdown is but I have a feeling this is a better job for Black to always insert parentheses around single-element tuples to make this obvious.
Not to deter adding this to bugbear, but flake8_tuple finds unintended tuples.