-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add flag for printing reports in colour #89
Conversation
This was last referenced in 44a7fed.
Before this change the logic for writing the report to stdout was a part of ChangeTracker. By extracting this to a separate class, we allow for other writer classes to be implemented.
I've taken this out of review for a moment, because I intend to do a refactor PR first, and land this afterwards. That'll make it easier to revamp #18 |
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.
Happy new year Charlie!
Thank you for this, I've raised a few suggestions.
Thanks for the review! I'll address your points so we can get this in, and then in contrast to what I said earlier, I'll do the refactor after :) |
@Tenzer I've addressed your points an rebased them in. The commit which changes is "Add ColorChangeReportWriter", and I have created one new commit, "Change spacing around report summary". |
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.
One minor thing left, then I think this is good to merge (assuming that you're ready for it - the PR is currently a draft).
I'll make a release when this has been merged in.
aef0e35
to
2530a10
Compare
All updated -- thank you! |
This class can be used to print out change reports in colour. The colours selected closely match those output by Mypy, with the exception that links are not highlighted in notes. The logic is inspired by Mypy's highlighting code. (See https://github.com/python/mypy/blob/f9e8e0bda5cfbb54d6a8f9e482aa25da28a1a635/mypy/util.py#L761) This supports only ANSI colours, so I suspect that this will not work on Windows.
Before this change an empty line would be printed above the summary when there were no new errors, and no empty line would be printed when there were errors. This change reverses that. An empty line is printed to separate the summary from the new errors only if there are new errors.
With this new
--color
(or--colour
, or-c
) flag, the error report can now be printed in colour.The selected colour scheme (mostly) matches that of Mypy. (I didn't bother adding URL highlighting in notes. Please let me know if you want this.)
I used ANSI colour codes for this to avoid adding a dependency, but please let me know if you would prefer this to make use of a library such as
rich
orcolorist
.Happy New Year!