E126: Problem with bad hanging & visual indents
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 42/100
Línea de trabajo
Comienza con la comprobación continued_indentation y sus pruebas asociadas; después, reproduce el ejemplo multilinea de rv.update del issue. Compara los diagnósticos reportados con las expectativas descritas: E126 en las líneas 2 y 3, y E128 en las líneas 4 y 5; actualiza las pruebas para capturar el comportamiento corregido.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 5.2k
- Forks
- 756
- Merge medio
- 5 h 56 min
- PR fusionados (30 d)
- 3
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PyCQA/pycodestyle
-
DOC: E252 is not documentedAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
PyCQA/pycodestyle#1294 · 1 comentario ·
-
Typing and formattingAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
PyCQA/pycodestyle#1302 · 3 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
PyCQA/pycodestyle#1242 · 2 comentarios ·
-
Spurious E231 for nested format substitutionsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
PyCQA/pycodestyle#1241 · 2 comentarios · 4 reacciones ·
-
`exclude` is applied to `.`Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
PyCQA/pycodestyle#1217 ·
Todos los issues de PyCQA/pycodestyle
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
onyx-dot-app/onyx#16016 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
black --check exits 0 and prints All done when a multi file run is interruptedPosiblemente ocupada @jiteshgulati la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
Non-positive worker counts wait for results without starting workersPosiblemente ocupada @IlyaKhalafi la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día