Change Ruff's text format to show the source code and context by default
#4189
MichaReiser
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Ruff's default
textformat only shows the file, location, and message of a reported violation without providing any additional context.This has the advantage that the output is very compact, which is especially useful when there are many diagnostics. However, I have found myself struggling with understanding diagnostics from just the brief (and very long) message. For example the following message:
crates/ruff/resources/test/cpython/Tools/unittestgui/unittestgui.py:107:9: E722 Do not use bare `except`As a Python beginner, I haven't heard of a bare
exceptbefore. Showing the source text would help me because I may at least be able to infer that it probably refers to theexceptwithout any specific exception, but only if I have the experience on why this might be bad. I recommend showing the suggested fix, if any, to help users understand how to solve the problem.The part I'm somewhat undecided on is whether we should show the explanation why this is bad. Showing the explanation can be useful to understand the problem but it can bloat every diagnostic quiet a bit.
What's your use case/opinion? Would you find it useful if ruff shows more descriptive diagnostics by default or do you prefer the compact rendering as it is today, and why?
Prior Art
Rome
main.tsx:1:15 [lint/correctness/noUnusedVariables](https://docs.rome.tools/lint/rules/noUnusedVariables) FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚠ This parameter is unused. > 1 │ function test(a, b) { │ ^ 2 │ 3 │ } ℹ Unused variables usually are result of incomplete refactoring, typos and other source of bugs. ℹ Suggested fix: If this is intentional, prepend a with an underscore. 1 │ - function·test(a,·b)·{ 1 │ + function·test(_a,·b)·{ 2 2 │ 3 3 │ }Clippy
Elm review
Beta Was this translation helpful? Give feedback.
All reactions