GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-140764: Make "missed comma" syntax warning less cryptic by alonme · Pull Request #140893 · python/cpython Conversation
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I was just working on this :) I was thinking of suggesting something like (as hinted): 1 Keep “perhaps” -> stays consistent with Python’s style. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@alonme In the future, when someone says they are working on something in the issue thread, please don't open a PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@StanFromIreland Sure, is there a rough guideline to how long after someone "claims" an issue is it okay to try and tackle it? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I'd recommend you wait at least three weeks, you can always ask. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Given that mentioning "sequence elements" isn't applicable to all scenarios, how about we simply make it generic and end the warning with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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\?' |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| 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\?' |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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\?' |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| 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\?' |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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\?' |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| 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\?' |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -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?". | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| 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?". |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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?", |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| "did you miss a comma to separate sequence elements?", | |
| "did you miss a comma to separate elements?", |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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?", |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| "did you miss a comma to separate sequence elements?", | |
| "did you miss a comma to separate elements?", |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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?", |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| "did you miss a comma to separate sequence elements?", | |
| "did you miss a comma to separate elements?", |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @ncoghlan! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.