Mypy should report errors when bpo-33346 would occur
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
https://bugs.python.org/issue33346 details some cases where you would get
SyntaxError: asynchronous comprehension outside of an asynchronous function
in some versions of Python, but mypy doesn't complain about these cases. Arguably this isn't necessarily specific to type checking, but it would be nice to report an error if Python is going to give a syntax error (even though it parses!)
I'm not quite sure what version of Python the fix (https://github.com/python/cpython/commit/054e9c84ac7c394941bba3ea1829d14dce1243fc) is in, but it would be nice to give an error message like "await cannot be used in dict comprehensions" in older versions of Python - especially because the error Python gives at runtime is not so good and doesn't include a line number, which gives a subpar experience trying to fix it - something mypy could provide a solution for.
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 damit, bpo-33346 und den referenzierten CPython-Commit zu lesen, um die Fälle von asynchronen Comprehensions und die betroffenen Python-Versionen zu identifizieren. Verfolge dann, wie mypy diese Konstrukte und seine versionsspezifischen Diagnosen behandelt; abgeschlossen ist die Aufgabe, wenn Ziele für ältere Versionen die ungültige await-Nutzung mit einer hilfreichen Zeilennummer melden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100