-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ruff autocompletion for --select rules #2808
Comments
Same for |
Probably has to do with the fact that we use a custom |
Yes there's indeed a way around this. I have already implemented this locally but would wait till #2517 is merged since that logic has to change when the |
For example: $ ruff check --select=EM<Tab> EM -- flake8-errmsg EM10 EM1 -- EM101 -- raw-string-in-exception EM102 -- f-string-in-exception EM103 -- dot-format-in-exception Fixes astral-sh#2808.
For example: $ ruff check --select=EM<Tab> EM -- flake8-errmsg EM10 EM1 -- EM101 -- raw-string-in-exception EM102 -- f-string-in-exception EM103 -- dot-format-in-exception Fixes astral-sh#2808.
For example: $ ruff check --select=EM<Tab> EM -- flake8-errmsg EM10 EM1 -- EM101 -- raw-string-in-exception EM102 -- f-string-in-exception EM103 -- dot-format-in-exception (You will need to enable autocompletion as described in the Autocompletion section in the README.) Fixes astral-sh#2808.
For example: $ ruff check --select=EM<Tab> EM -- flake8-errmsg EM10 EM1 -- EM101 -- raw-string-in-exception EM102 -- f-string-in-exception EM103 -- dot-format-in-exception (You will need to enable autocompletion as described in the Autocompletion section in the README.) Fixes astral-sh#2808.
For example: $ ruff check --select=EM<Tab> EM -- flake8-errmsg EM10 EM1 -- EM101 -- raw-string-in-exception EM102 -- f-string-in-exception EM103 -- dot-format-in-exception (You will need to enable autocompletion as described in the Autocompletion section in the README.) Fixes astral-sh#2808.
For example: $ ruff check --select=EM<Tab> EM -- flake8-errmsg EM10 EM1 -- EM101 -- raw-string-in-exception EM102 -- f-string-in-exception EM103 -- dot-format-in-exception (You will need to enable autocompletion as described in the Autocompletion section in the README.) Fixes astral-sh#2808. (The --help help change in the README is due to a clap bug, for which I already submitted a fix: clap-rs/clap#4710.)
For example: $ ruff check --select=EM<Tab> EM -- flake8-errmsg EM10 EM1 -- EM101 -- raw-string-in-exception EM102 -- f-string-in-exception EM103 -- dot-format-in-exception (You will need to enable autocompletion as described in the Autocompletion section in the README.) Fixes #2808. (The --help help change in the README is due to a clap bug, for which I already submitted a fix: clap-rs/clap#4710.)
I tried too long for myself but failed with: diff --git crates/ruff_cli/src/args.rs crates/ruff_cli/src/args.rs
index 445534c7..e69bb043 100644
--- crates/ruff_cli/src/args.rs
+++ crates/ruff_cli/src/args.rs
@@ -38,7 +38,7 @@ pub enum Command {
#[clap(alias = "--explain")]
Rule {
#[arg(value_parser=Rule::from_code)]
- rule: Rule,
+ rule: RuleSelector,
/// Output format
#[arg(long, value_enum, default_value = "pretty")]
diff --git crates/ruff_cli/src/main.rs crates/ruff_cli/src/main.rs
index cf806cde..ea3af2b4 100644
--- crates/ruff_cli/src/main.rs
+++ crates/ruff_cli/src/main.rs
@@ -8,6 +8,7 @@ use clap::{CommandFactory, Parser, Subcommand};
use colored::Colorize;
use notify::{recommended_watcher, RecursiveMode, Watcher};
+use ruff::registry::Rule;
use ::ruff::logging::{set_up_logging, LogLevel};
use ::ruff::resolver::PyprojectDiscovery;
use ::ruff::settings::types::SerializationFormat;
@@ -107,7 +108,7 @@ quoting the executed command, along with the relevant file contents and `pyproje
set_up_logging(&log_level)?;
match command {
- Command::Rule { rule, format } => commands::rule::rule(&rule, format)?,
+ Command::Rule { rule, format } => commands::rule::rule(&Rule::from_code(rule.prefix_and_code().1).unwrap(), format)?,
Command::Config { option } => return Ok(commands::config::config(option.as_deref())),
Command::Linter { format } => commands::linter::linter(format)?,
Command::Clean => commands::clean::clean(log_level)?, Also how can I enable that it displays the short-code like in the PR?:
for me it displays only the raw codes. |
I am currently busy with other stuff.
I don't know I am using Zsh and this just worked ... are you using a different shell? |
I am using |
Ah ok yeah ... sorry it appears that
I can recommend zsh ... it does in general have much better autocompletion than bash. |
ok, thanks |
ruff check --select E
currently suggests filenames starting withE
instead of the rules starting withE
.It would be nice if that was supported for
--select
,--ignore
, etc.The text was updated successfully, but these errors were encountered: