Skip to content

Conversation

@alonme
Copy link
Contributor

@alonme alonme commented Nov 1, 2025

@7576457
Copy link

7576457 commented Nov 1, 2025

I was just working on this :)

I was thinking of suggesting something like (as hinted):
"perhaps you missed a comma to separate sequence elements?"

1 Keep “perhaps” -> stays consistent with Python’s style.
2 Add “to separate sequence elements” -> makes it clear that it’s about lists, tuples, function arguments, etc.

@StanFromIreland
Copy link
Member

@alonme In the future, when someone says they are working on something in the issue thread, please don't open a PR.

@alonme
Copy link
Contributor Author

alonme commented Nov 1, 2025

@StanFromIreland Sure, is there a rough guideline to how long after someone "claims" an issue is it okay to try and tackle it?

@StanFromIreland
Copy link
Member

Sure, is there a rough guideline to how long after someone "claims" an issue is it okay to try and tackle it?

I'd recommend you wait at least three weeks, you can always ask.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not only for sequence elements. You get the same warning for set and dict which are not sequences. And for function arguments.

>>> {(1, 2) (3, 4)}
<python-input-0>:1: SyntaxWarning: 'tuple' object is not callable; perhaps you missed a comma?
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    {(1, 2) (3, 4)}
     ~~~~~~~^^^^^^
TypeError: 'tuple' object is not callable
>>> print((1, 2) (3, 4))
<python-input-1>:1: SyntaxWarning: 'tuple' object is not callable; perhaps you missed a comma?
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    print((1, 2) (3, 4))
          ~~~~~~~^^^^^^
TypeError: 'tuple' object is not callable

@tadejmagajna
Copy link
Contributor

Given that mentioning "sequence elements" isn't applicable to all scenarios, how about we simply make it generic and end the warning with ...; did you miss a comma to separate elements?

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

Several suggestions added to tweak the wording as per the comments from @serhiy-storchaka and @tadejmagajna, along with a corresponding adjustment to the news message.

(I'm skipping setting the "request changes" flag, as folks shouldn't feel obliged to wait for a second review specifically from me once the wording has been updated)

self.check_syntax_warning(test, msg)

msg=r'is not callable; perhaps you missed a comma\?'
msg=r'is not callable; did you miss a comma to separate sequence elements\?'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg=r'is not callable; did you miss a comma to separate sequence elements\?'
msg=r'is not callable; did you miss a comma to separate elements\?'

check('[t"x={x}" (3, 4)]')

msg=r'is not subscriptable; perhaps you missed a comma\?'
msg=r'is not subscriptable; did you miss a comma to separate sequence elements\?'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg=r'is not subscriptable; did you miss a comma to separate sequence elements\?'
msg=r'is not subscriptable; did you miss a comma to separate elements\?'

check('[t"x={x}" [i, j]]')

msg=r'indices must be integers or slices, not tuple; perhaps you missed a comma\?'
msg=r'indices must be integers or slices, not tuple; did you miss a comma to separate sequence elements\?'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg=r'indices must be integers or slices, not tuple; did you miss a comma to separate sequence elements\?'
msg=r'indices must be integers or slices, not tuple; did you miss a comma to separate elements\?'

@@ -0,0 +1 @@
Improve syntax warning messages for missing commas in sequences. The messages now say "did you miss a comma to separate sequence elements?" instead of "perhaps you missed a comma?".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Improve syntax warning messages for missing commas in sequences. The messages now say "did you miss a comma to separate sequence elements?" instead of "perhaps you missed a comma?".
Improve the suggestion in syntax warning messages for potentially missing commas when defining containers. The messages now say "did you miss a comma to separate elements?" instead of "perhaps you missed a comma?".

Python/codegen.c Outdated
location loc = LOC(e);
return _PyCompile_Warn(c, loc, "'%.200s' object is not callable; "
"perhaps you missed a comma?",
"did you miss a comma to separate sequence elements?",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"did you miss a comma to separate sequence elements?",
"did you miss a comma to separate elements?",

Python/codegen.c Outdated
location loc = LOC(e);
return _PyCompile_Warn(c, loc, "'%.200s' object is not subscriptable; "
"perhaps you missed a comma?",
"did you miss a comma to separate sequence elements?",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"did you miss a comma to separate sequence elements?",
"did you miss a comma to separate elements?",

Python/codegen.c Outdated
return _PyCompile_Warn(c, loc, "%.200s indices must be integers "
"or slices, not %.200s; "
"perhaps you missed a comma?",
"did you miss a comma to separate sequence elements?",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"did you miss a comma to separate sequence elements?",
"did you miss a comma to separate elements?",

@alonme
Copy link
Contributor Author

alonme commented Jan 26, 2026

Thanks @ncoghlan!
Fixed per your review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants