python / python/mypy

"# E:" lines (etc) in test files are ignored at the beginning of lines

Offen
#19,547 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

topic-developer topic-tests
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

As discovered in the unrelated https://github.com/python/mypy/pull/19494#discussion_r2243899624, "# E:" lines (etc) in test files are ignored at the beginning of lines. Having looked at the code, I've discovered this is because it desires the # to be preceded by a space, which is not present when the # is at the beginning of a line. This is bad because attempted error lines should not be silently ignored. (Although it is unlikely for someone to try to E an empty line.)

My PR #19546 will fix this. Edit: that would still be true, but #21172 is a much more minimal fix for this.

Easy repro:

[case testErrorCodeOnEmptyLine]
# E: This isn't a real message, and thus this test could never pass, although somehow it currently does :)

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit mypy/test/data.py etwa um Zeile 536 und reproduziere das Verhalten anhand des im Issue gezeigten Testfalls. Vergleiche den vorgeschlagenen minimalen Fix in Issue #21172, da im Body steht, dass der umfassendere Ansatz in PR #19546 nicht mehr bevorzugt wird. Erledigt bedeutet, dass die ungültige „# E:“Assertion am Zeilenanfang nicht mehr stillschweigend ignoriert wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
testing-qa
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
20/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.