Extend operator-typo SyntaxError suggestions (`=<`, `=>`, `=!`) to `if/while` other conditions
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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 theif/whilecase.
Originally posted by @pablogsal in https://github.com/python/cpython/pull/151375#discussion_r3683730462
I'm planning to work on this and submit a PR shortly after the follow up merged, please avoid PR in this
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem Lesen von PR #151375 und der bestehenden SyntaxError-Vorschlagsimplementierung, um zu verstehen, wie Tippfehler bei Operatoren für nackte Anweisungen erkannt werden. Erweitere das Verhalten auf if, while und andere Bedingungsfälle. Füge anschließend Tests hinzu oder aktualisiere sie, um diese Formen abzudecken, und überprüfe die vorgeschlagenen Meldungen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100