Conversation
Summary -- Fixes astral-sh/ty#2061. I really just wanted a list of rules for my categorization work, but I found the issue, and Claude knocked it out quickly. No pressure to land (or review) this if there's more to it, I see that the issue is labeled `wish`. Test Plan -- New CLI tests mirroring the ones for Ruff
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 85.05%. The percentage of expected errors that received a diagnostic held steady at 78.05%. The number of fully passing files held steady at 63/132. |
|
Memory usage reportMemory usage unchanged ✅ |
MichaReiser
left a comment
There was a problem hiding this comment.
Thank you. This looks good. I only have some bikeshedding questions.
Long term, it would be nice if there was also a command to explain:
- categories
- settings
- non-rule codes
One option is to group all those under an explain command: ty explain rule <code>, ty explain setting, ty explain category.
I'm not sure what the best approach is regarding non-rule codes. ty explain code and ty explain lint are both unfamiliar terms for users. So I think I'm fine going with rule for now, unless you have a better idea.
crates/ty/src/args.rs
Outdated
| /// Explain all rules | ||
| #[arg(long, conflicts_with = "rule", group = "selector")] | ||
| all: bool, |
There was a problem hiding this comment.
I feel like we should simply default to all if the command is called without any arguments.
There was a problem hiding this comment.
Makes sense to me, I was just following Ruff.
crates/ty/src/rule.rs
Outdated
| let mut stdout = BufWriter::new(io::stdout().lock()); | ||
| match format { | ||
| HelpFormat::Text => { | ||
| writeln!(stdout, "{}", format_rule_text(lint))?; |
There was a problem hiding this comment.
Should we implement Display for Explanation instead? It would make the two branches more similar.
There was a problem hiding this comment.
Yep, makes sense! That would probably be nicer in Ruff too.
|
Thanks for the review! I implemented
I do like the idea of an All that to say I don't really have a better idea. But I'm happy to change the subcommand name to |
It might be worth going back to see if Ruff used to use I think I prefer |
|
It looks like we did use
so I guess it just depends if we want to stick with that and have separate top-level subcommands for each type or nest them all under the This also raises another possibility for I don't feel super strongly either way but do slightly prefer the look of: $ ty rule
$ ty category
$ ty settingover $ ty explain rule
$ ty explain category
$ ty explain settingand at least it matches Ruff too. |
|
I prefer a separate subcommand. Top level commands have a high cognitive overhead and it's also unclear what I prefer |
|
Sounds good, I switched it to |
Summary
Fixes astral-sh/ty#2061 by adding a top-level
ty explainsubcommand with arulesubcommand under it. By defaultty explain ruledescribes all known lint rules, whilety explain rule <RULE>explains a specific rule. Both thetextandjsonformats are supported with the--output-formatflag.Test Plan
New CLI tests mirroring the ones for Ruff
Examples