Skip to content

bpo-15248: Emit a compiler warning when missed a comma before tuple or list.#11757

Merged
serhiy-storchaka merged 4 commits intopython:masterfrom
serhiy-storchaka:compile-warn-perhaps-missed-comma
Feb 16, 2019
Merged

bpo-15248: Emit a compiler warning when missed a comma before tuple or list.#11757
serhiy-storchaka merged 4 commits intopython:masterfrom
serhiy-storchaka:compile-warn-perhaps-missed-comma

Conversation

@serhiy-storchaka
Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka commented Feb 4, 2019

Copy link
Copy Markdown
Contributor

@SylvainDe SylvainDe left a comment

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).

@serhiy-storchaka serhiy-storchaka force-pushed the compile-warn-perhaps-missed-comma branch from ab03389 to cfe1a8d Compare February 5, 2019 04:14
@serhiy-storchaka serhiy-storchaka force-pushed the compile-warn-perhaps-missed-comma branch from cfe1a8d to 8e9dc9c Compare February 5, 2019 05:02
Copy link
Copy Markdown
Contributor

@SylvainDe SylvainDe left a comment

Choose a reason for hiding this comment

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

I like this!

Copy link
Copy Markdown
Member

@gvanrossum gvanrossum left a comment

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.

Comment thread Python/compile.c Outdated
case JoinedStr_kind:
case FormattedValue_kind:
return compiler_warn(c, "'%.200s' object is not callable, "
"perhaps missed a comma?",
Copy link
Copy Markdown
Member

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.

Comment thread Python/compile.c Outdated
case GeneratorExp_kind:
case Lambda_kind:
return compiler_warn(c, "'%.200s' object is not subscriptable, "
"perhaps missed a comma?",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto.

@serhiy-storchaka
Copy link
Copy Markdown
Member Author

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.

@serhiy-storchaka serhiy-storchaka merged commit 62e4481 into python:master Feb 16, 2019
@serhiy-storchaka serhiy-storchaka deleted the compile-warn-perhaps-missed-comma branch February 16, 2019 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants