Skip to content

Make "perhaps you missed a comma?" hint in syntax warnings less cryptic #140764

@ncoghlan

Description

@ncoghlan

Feature or enhancement

Proposal:

Syntax warnings for code like [][""], [](), and 1[2] finish with the hint "perhaps you missed a comma?"

>>> lambda: 1[2]
<python-input-23>:1: SyntaxWarning: 'int' object is not subscriptable; perhaps you missed a comma?
<function <lambda> at 0x705dfb04b920>

When this came up in a review of currently emitted syntax warnings, it took me a moment to realise that it was suggesting the two subexpressions might have been supposed to be separate items in a sequence definition.

While I expect this would be clearer in the context of an actual warning, in isolation it felt very cryptic. Perhaps it would make sense to expand the hint to "did you miss a comma to separate sequence elements?"

Edit: Amended proposed text as @hugovk suggested

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    easyinterpreter-core(Objects, Python, Grammar, and Parser dirs)triagedThe issue has been accepted as valid by a triager.type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions