bpo-15248: Emit a compiler warning when missed a comma before tuple or list. by serhiy-storchaka · Pull Request #11757 · python/cpython
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very cool!
As an additional comment/question: would it make sense to move the logic generating the type description from the expr_ty into a function on its own to limit duplication ? I gave it a try at https://pastebin.com/XLZ2B7Cq (not tested whatsoever).
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this!
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this! Just some suggestions on the error messages.
| case JoinedStr_kind: | ||
| case FormattedValue_kind: | ||
| return compiler_warn(c, "'%.200s' object is not callable, " | ||
| "perhaps missed a comma?", |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“perhaps you missed a comma?”
Also use “;” instead of “,” on the previous line.
| case GeneratorExp_kind: | ||
| case Lambda_kind: | ||
| return compiler_warn(c, "'%.200s' object is not subscriptable, " | ||
| "perhaps missed a comma?", |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
Thank you @SylvainDe! I also thought about this type of simplification, but was hesitant. I initially implemented this idea independently, but then I seen your nice variant and borrowed it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters