-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lint YAML files #1039
Lint YAML files #1039
Conversation
guillett
commented
Jul 13, 2018
- Amélioration technique.
- Détails :
- Ajout d'un linter pour les fichiers YAML
Cette PR est une étape vers la normalisation des fichiers YAML. Il y a des warnings non bloquants pour cette PR mais à traiter avant de pouvoir manipuler systématiquement les fichiers YAML. |
* Required to pass ruamel.yaml roundtrip test
* ' false' 840 matches across 259 files * ' False' 84 matches across 20 files * ' true' 500 matches across 276 files * ' True' 186 matches across 24 files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on the linting !
I would add a make lint
that would run yamllint on test and parameter.
.circleci/config.yml
Outdated
@@ -23,19 +23,24 @@ jobs: | |||
name: Install dependencies | |||
command: | | |||
pip install --upgrade pip twine wheel | |||
pip install --editable .[test] --upgrade | |||
pip install --editable .[test,lint] --upgrade |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not put the linter with the test dependencies ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pour apporter de la granularité aux niveaux des dépendances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dans quel cas concret cette granularité est-elle souhaitable?
Le package yamllint
est-il connu pour être difficile à installer dans certains environnements?
S'agit-il d'un package très lourd qui ralentit significativement l'installation?
Un linter me paraît être typiquement une dépendance de développement, au même titre que nose ou flake8. S'il n'y a pas de raison particulière, je suis pour qu'on le mette dans test
, avec les autres dépendances de dev.
(Il y a déjà bien trop d'extra-dépendances sur France.)
# pip install --editable git+https://github.com/openfisca/openfisca-core.git@BRANCH_NAME#egg=OpenFisca-Core # use a specific branch of OpenFisca-Core | ||
|
||
- save_cache: | ||
key: v1-py2-{{ checksum "setup.py" }} | ||
paths: | ||
- /tmp/venv/openfisca_france | ||
|
||
- run: | ||
name: Lint YAML files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, why not put it in the run test
part ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and why not run the linter on all yaml files (expecially the parameters ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it seems to me that a test with a unvalid yaml fails with openfisca-run-test. Is this to fail faster ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Un linter (comme flake8) fait plus que détecter les erreurs de syntaxe, il impose aussi des bonnes pratiques et une consistence qui permettent d'avoir un code plus propre.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Les règles de gestion du yamllint
me paraissent trop "relaxées" pour jouer ce rôle de bonne pratiques. C'est pour cela que je posait la question que peut être il était surtout utilisait comme validateur.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anna-Livia je ne comprends pas ta remarque, as-tu un lien vers CircleCI ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contrairement à ce qu'on peut passer circleci tests glob "**/*.yaml"
correspond à ls **/*.yaml
et non pas ls tests/**/*/yaml
. L'outil fourni par CircleCI est initialement fait pour les tests ; c'est de là que vient le préfix circleci tests
dans les commandes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'espérais que cette PR soit mergée dans la semaine et itérer sur une nouvelle base cette semaine. yamllint
génére aujourd'hui beaucoup d'avertissements qui restent à être gérés. Une fois les modifications nécessaires apportées aux fichiers YAML les problèmes de format généreront des erreurs et non plus des avertissements.
.circleci/config.yml
Outdated
- run: | ||
name: Run tests | ||
command: | | ||
nosetests `circleci tests glob "tests/**/*.py" | circleci tests split` | ||
openfisca-run-test `circleci tests glob "tests/**/*.{yaml,yml}" | circleci tests split` | ||
openfisca-run-test `circleci tests glob "tests/**/*.yaml" | circleci tests split` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it me or do we not pass flake8 on circle ci ? (cc @fpagnoux )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pas sur OpenFisca-France. Personne n'a eu la motivation/volonté pour ajuster la configuration flake et corriger les 3644 erreurs flake présentes aujourd'hui.
.circleci/config.yml
Outdated
- run: | ||
name: Run tests | ||
command: | | ||
nosetests `circleci tests glob "tests/**/*.py" | circleci tests split` | ||
openfisca-run-test `circleci tests glob "tests/**/*.{yaml,yml}" | circleci tests split` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quel avantage à ne plus gérer les fichiers avec une extension .yml
? Il n'y a pas un risque qu'un contributeur en créé un par accident?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'oublie toujours la forme que doit prendre l'expression régulière qui effectue un OU.
Ne pas gérer les deux c'est simplifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Le risque qu'un contributeur créé un fichier de test en .yml
et que ça ne soit pas détecté à la revue (qui regarde les extensions?) me paraît loin d'être anecdotique.
La simplification de cette ligne, plutôt compréhensible à la lecture, me paraît un gain léger comparé aux problèmes que pourraient poser la présence de tests non exécutés.
Pour info, en faisant passer le script de performance (et en augmentant la
|
Merci @Anna-Livia et @fpagnoux pour vos commentaires. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Points bloquants pour moi:
- Retrait du support des fichiers
.yml
- Ajout d'une extra dépendance