Skip to content

Extend operator-typo SyntaxError suggestions (=<, =>, =!) to if/while other conditions #154970

Description

@Aniketsy

Follow-up #151375

In that PR we added helpful SyntaxError messages for common operator typos: =< suggests <=, => suggests >=, and =! suggests !=.

These suggestions currently only work when the typo appears in a plain statement. like

'a => b' invalid syntax. Maybe you meant '>=' instead of '=>'?

So this is for extending in if, while, or other conditions:

These only fire for bare statements, so if a => b: still gives the generic error, no? That is probably fine for a first iteration (the = < tokenization makes it look like an assignment), but maybe we should add a test documenting it or a follow-up issue for the if/while case.

Originally posted by @pablogsal in #151375 (comment)

I'm planning to work on this and submit a PR shortly after the follow up merged, please avoid PR in this

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions