E126: Problem with bad hanging & visual indents
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 42/100
Rechercherichtung
Beginnen Sie mit dem continued_indentation-Check und den zugehörigen Tests, und reproduzieren Sie anschließend das mehrzeilige rv.update-Beispiel aus dem Issue. Vergleichen Sie die gemeldeten Diagnosen mit den beschriebenen Erwartungen: E126 in den Zeilen 2 und 3 sowie E128 in den Zeilen 4 und 5; aktualisieren Sie die Tests, um das korrigierte Verhalten zu erfassen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
While trying to work out the kinks in my attempted fix for issue #667, I realised the indentation checks are more broken than I expected.
This test is in the test suite:
#: E126 E126
rv.update(dict.fromkeys((
'qualif_nr', 'reasonComment_en', 'reasonComment_fr',
'reasonComment_de', 'reasonComment_it'),
'?'),
"foo")
Currently this test passes, but it shouldn't. With the following line numbers (don't know how to make line nums show up in github code blocks?):
1 rv.update(dict.fromkeys((
2 'qualif_nr', 'reasonComment_en', 'reasonComment_fr',
3 'reasonComment_de', 'reasonComment_it'),
4 '?'),
5 "foo")
pycodestyle reports E126 (continuation line over-indented for hanging indent) for lines 2 and 4, and no other errors, and so the test passes. But looking at the PEP 8 guidelines on hanging indents:
When using a hanging indent the following should be considered; there should be no arguments on the first line...
Since three bracketed blocks are opened on line 1, only the innermost one should qualify as a possible hanging indent. So lines 2 and 3 are over-indented hanging indents and should report E126 (currently 2 does and 3 doesn't).
Lines 4 and 5 can't be hanging indents as each of their bracket-blocks' first arguments begin on the same line as their opening bracket (i.e. line 1). Hence line 4 is erroneously reported as E126, and both of these lines should be reported as under-indented visual indents (E128), which neither of them currently are (5 gets no report, 4 gets the erroneous E126 as mentioned).
As a sanity-check, I ran pylint on the above file, which flagged "wrong hanging indentation" for lines 2 and 3, and "wrong continued indentation" for lines 4 and 5, which matches with my reasoning above.
I think this might need a fairly substantial rewrite of the continued_indentation check and associated tests. I don't have any time in the next week, but if nobody else takes it on I would be happy to have a look at it when I have time.
- Vorherrschende Sprache
- Python
- Sterne
- 5.2k
- Forks
- 760
- Ø Merge
- 5 Std. 56 Min.
- Gemergte PRs (30 T.)
- 3
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus PyCQA/pycodestyle
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
PyCQA/pycodestyle#1294 · 1 Kommentar ·
-
Typing and formattingOffen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
PyCQA/pycodestyle#1302 · 3 Kommentare ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 42/100
PyCQA/pycodestyle#1242 · 2 Kommentare ·
-
Spurious E231 for nested format substitutionsEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
PyCQA/pycodestyle#1241 · 2 Kommentare · 4 Reaktionen ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
PyCQA/pycodestyle#1217 ·
Alle Issues in PyCQA/pycodestyle
Ähnliche Issues
-
documentation good first issue
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 72/100
sujithputta02/Esapay#13 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
Flaky: credential-proxy admission metric test asserts a wall-clock bound it does not establishOffenneeds-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
gke-labs/kube-agents#3277 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
jbacalso24/mimry#291 ·
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
eli-alvarado/us-watchlist-alerts#14 ·
Maintainer antworten meist innerhalb von 1 Tag