-
Notifications
You must be signed in to change notification settings - Fork 2
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
cli: Introduce new --format
argument (and remove --xunit-file
)
#14
Conversation
2525abb
to
6517863
Compare
3fc73ee
to
9736311
Compare
ok_msg = err_msg = "" | ||
if has_old_branches: | ||
err_msg = "NOK: Some branches are too old." | ||
print(err_msg) | ||
else: | ||
err_msg = "" | ||
print("OK: All branches are fresh.") | ||
if out: | ||
print(out) | ||
ok_msg = "OK: All branches are fresh." |
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.
Plutôt que d'initialiser des variables qu'on va modifier ou non, on pourrait avoir une petite fonction get_messages(has_old_branches: bool) -> tuple[str, str]
?
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.
Mouais, je ne suis pas convaincu. :) Là, on a bout de code de 5 lignes, simple, clair, direct. Je trouve ça plus parlant qu'un appel à une fonction.
src/check_oldies/check_fixmes.py
Outdated
|
||
# Look for orphan FUTURE tags | ||
orphan_futures = annotations.get_orphan_futures(config) | ||
for orphan in orphan_futures: | ||
out.append(warn(orphan_str(orphan))) | ||
uncolorized_out.append(orphan_str(orphan)) | ||
orphan_futures = check_oldies.annotations.get_orphan_futures(config) | ||
|
||
out = os.linesep.join(out) | ||
ok_msg = err_msg = "" |
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.
Pareil que pour check-branches
# we'll have to make sure that we can do that and still support 3.8 | ||
# and 3.9). or perhaps get rid of it? |
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.
3.8 and 3.9 should not be supported as they are near the end of their security cycle and close to end-of-life : https://devguide.python.org/versions/
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.
What are potential limitations regarding 3.8 and 3.9 ?
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.
I am not inclined to remove support of versions that have not yet reached their end of life (however old they might be).
if error_message: | ||
lines.append(warn(error_message)) |
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 de couleur spécifique aux erreurs pour les différencier des alertes ?
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.
Qu'est-ce qu'une erreur, qu'est-ce qu'une alerte ?
On a 2 sortes de lignes :
- lignes informatives : "t'as un FIXME, il a 3 jours, je t'informe, tout va bien"
- lignes d'erreur : "t'as un FIXME, il a 200 jours, c'est une erreur"
Les premières sont affichées dans la couleur par défaut du terminal. Les secondes sont affichées en rouge.
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'ai peut-être mal compris mais je vois ok_message, error_message et must_warn alors j'ai pensé à 3 echelons
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.
must_warn
indique une ligne d'erreur : une annotation ou une branche trop vieille (ou un tag "future" orphelin).
src/check_oldies/output.py
Outdated
raise ValueError(f"Unknown output format: '{format_}'") | ||
|
||
|
||
def printer(objects: list, output_format, **options): |
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.
objects: list, output_format: OutputFormat
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.
bien vu, c'est fait
src/check_oldies/output.py
Outdated
return xml.etree.ElementTree.tostring(suite, encoding="utf-8").decode("utf-8") | ||
|
||
|
||
def get_formatter(format_) -> typing.Callable: |
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.
output_format
plutôt que format_
?
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.
c'est fait
tests/test_check_branches.py
Outdated
@@ -113,17 +114,17 @@ def test_output_old_branches(capfd): # capfd is a pytest fixture | |||
assert stdout == expected | |||
|
|||
|
|||
def test_xunit_file_generation(tmp_path): # tmp_path is a pytest fixture | |||
xunit_path = tmp_path / "xunit.xml" | |||
def test_xunit_file_generation(capfd): # capfd is a pytest fixture |
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.
use linting instead of comment :)
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.
c'est fait
# `xml.etree.ElementTree.tostring()` preserves attribute order only as of | ||
# Python 3.8. With prior versions, we cannot easily compare XML | ||
# output, so don't bother. | ||
HAS_UNSORTED_XML_WRITE = sys.version_info[:2] < (3, 8) |
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.
Python minimal version supported is 3.8. So we can remove all logic link to that
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.
Oui, dans une autre pull request où je supprimerai le support de Python 3.7 (entre autres modernisations).
2cf5881
to
29dbfb3
Compare
Any output (text or xUnit) is now directed to the standard output. It will be easier to add new formats (such as CSV or JSON, which I plan). If you used the `--xunit-file`, you must now use `--format` and redirect the standard output to a file.
29dbfb3
to
e39fa46
Compare
`check-branches`, `check-fixmes` and `check-futures` commands now accept a `--format csv` argument. Example:
By default, all commands show all annotations, branches, etc., including those that are recent. When exporting to a CSV format, it's useful to filter out the recent items and only display old ones.
It's a (relative) path, not a mere filename.
e39fa46
to
2f3cdb5
Compare
@sandre35 et @TiphaineLAURENT : J'ai pris en compte tous les commentaires (parmi ceux que je souhaitais prendre en compte ;) ), rebasé par rapport à master... et ai push-forcé comme un sauvageon. :) J'ai aussi corrigé divers oublis, comme la mise à jour du changelog et de la doc. La pull request m'a l'air à peu près complète, désormais, prête à être mergée. |
6cb8bae
to
d479f31
Compare
Any output (text or xUnit) is now directed to the standard output. It
will be easier to add new formats (such as CSV or JSON, which I plan).