-
Notifications
You must be signed in to change notification settings - Fork 468
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
RFC: improve diagnostic formatting #3258
Comments
Removed or changed to |
Yes. My idea was to have the default format be "plain" (and However, as I wrote, the way the context is written should probably be modified, in order to improve readability. An example is a format that prints a JSON document. |
I'm planning to implement the diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
index 6e3662a8..40683357 100644
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -994,14 +994,14 @@ def parse_file(
print_context(lines, i, context)
if filename != "-":
print(
- f"{cfilename}:{cline}: {cwrongword} "
+ f"{cfilename}:{cline}:x {cwrongword} "
f"==> {crightword}{creason}"
)
elif options.stdin_single_line:
print(f"{cline}: {cwrongword} ==> {crightword}{creason}")
else:
print(
- f"{cline}: {line.strip()}\n\t{cwrongword} "
+ f"{cline}: {line.strip()}x\n\t{cwrongword} "
f"==> {crightword}{creason}"
)
there was no test failure. My suggestion is:
What do you think? |
Any news about this proposal? |
In #3256 I introduced the
--caret-diagnostic
flag in order to report the diagnostic message as it is done by modern compilers.The name of the flag is derived from https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fcaret-diagnostics (though I missed the ending
s
).@peternewman suggested to add a
--format
flag, instead, in order to be future proof.Since this requires more changes to the current code, I would like to open a discussion about the best strategy.
The main problem is how the context (
-C
/-A
/-B
) is applied. Here is an example:This works only when there is one line.
--format flag
Introducing the
--format
flag has the advantage that we know how many context source lines are printed by a format, so with-C
/-A
/-B
the code only needs to print additional lines around the lines printed by the format.Possible formats:
plain (default)
Not sure if
ccolumn
can be added.diagnostic / caret-diagnostics / develop/ ?
TODO
Not sure if the code in interactive mode should also be modified. Example:
The same line is printed twice; not sure if it is a good user experience.
Another issue I found is:
Should we have the second template be an alternative format?
Should the
--stdin_single_line
flag be removed before the next release?Thanks.
The text was updated successfully, but these errors were encountered: