question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Detect unintended comma at the end of expression

See original GitHub issue

I 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:open
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
ambvcommented, Mar 20, 2018

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.

1reaction
gaulcommented, Jun 13, 2018

Not to deter adding this to bugbear, but flake8_tuple finds unintended tuples.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found