E126: Problem with bad hanging & visual indents
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 42/100
Piste de recherche
Commencez par le contrôle continued_indentation et les tests associés, puis reproduisez l’exemple multiligne de rv.update présent dans l’issue. Comparez les diagnostics signalés aux attentes décrites : E126 aux lignes 2 et 3, et E128 aux lignes 4 et 5 ; mettez à jour les tests pour capturer le comportement corrigé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 5.2k
- Forks
- 760
- Merge moyen
- 5 h 56 min
- PR mergées (30 j)
- 3
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de PyCQA/pycodestyle
-
DOC: E252 is not documentedOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
PyCQA/pycodestyle#1294 · 1 commentaire ·
-
Typing and formattingOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
PyCQA/pycodestyle#1302 · 3 commentaires ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 42/100
PyCQA/pycodestyle#1242 · 2 commentaires ·
-
Spurious E231 for nested format substitutionsPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
PyCQA/pycodestyle#1241 · 2 commentaires · 4 réactions ·
-
`exclude` is applied to `.`Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
PyCQA/pycodestyle#1217 ·
Toutes les issues de PyCQA/pycodestyle
Issues similaires
-
fix formatting of the sample database page of the docsPeut-être pris @Aaqibhafeezkhan l’a pris aujourd’hui. Ouvertedocumentation good first issue help wanted
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
chaoss/CollectOSS#544 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
area/plugin good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
kestra-io/plugin-soda#137 ·
-
Difficulté 2/5 Une demi-journée Accessibilité débutants 62/100
ibm-granite/granite.build#504 ·
Les mainteneurs répondent en général sous 2 jours
-
`LazyFrameRemote` and `ExecuteRemote` sinks do not accept `Path`, like `LazyFrame` sinks do.Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour