diff --git a/.github/workflows/ruff.yaml b/.github/workflows/ruff.yaml index 72aeaedf82608..ff698d34d0630 100644 --- a/.github/workflows/ruff.yaml +++ b/.github/workflows/ruff.yaml @@ -138,7 +138,7 @@ jobs: with: target: ${{ matrix.target }} manylinux: auto - args: --no-default-features --release --out dist + args: --release --out dist - uses: uraimo/run-on-arch-action@v2.5.0 if: matrix.target != 'ppc64' name: Install built wheel diff --git a/Cargo.lock b/Cargo.lock index e2241b647309f..fb56e9b0a46bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -608,15 +608,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "directories" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs" version = "4.0.0" @@ -2007,7 +1998,6 @@ dependencies = [ "similar", "strum", "textwrap", - "update-informer", "ureq", "walkdir", ] @@ -2758,19 +2748,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" -[[package]] -name = "update-informer" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "152ff185ca29f7f487c51ca785b0f1d85970c4581f4cdd12ed499227890200f5" -dependencies = [ - "directories", - "semver", - "serde", - "serde_json", - "ureq", -] - [[package]] name = "ureq" version = "2.6.2" @@ -2782,8 +2759,6 @@ dependencies = [ "log", "once_cell", "rustls", - "serde", - "serde_json", "url", "webpki", "webpki-roots", diff --git a/README.md b/README.md index 94dea622b57f2..9e92cb93956b5 100644 --- a/README.md +++ b/README.md @@ -476,8 +476,6 @@ Miscellaneous: The name of the file when passing it through stdin -e, --exit-zero Exit with status code "0", even upon detecting lint violations - --update-check - Enable or disable automatic update checks Log levels: -v, --verbose Enable verbose logging diff --git a/ruff_cli/Cargo.toml b/ruff_cli/Cargo.toml index dddccdaa5cce0..fdfe62eaae0de 100644 --- a/ruff_cli/Cargo.toml +++ b/ruff_cli/Cargo.toml @@ -51,7 +51,6 @@ serde = { version = "1.0.147", features = ["derive"] } serde_json = { version = "1.0.87" } similar = { version = "2.2.1" } textwrap = { version = "0.16.0" } -update-informer = { version = "0.6.0", default-features = false, features = ["pypi"], optional = true } walkdir = { version = "2.3.2" } strum = "0.24.1" @@ -60,10 +59,6 @@ assert_cmd = { version = "2.0.4" } strum = { version = "0.24.1" } ureq = { version = "2.5.0", features = [] } -[features] -default = ["update-informer"] -update-informer = ["dep:update-informer"] - [package.metadata.maturin] name = "ruff" # Setting the name here is necessary for maturin to include the package in its builds. diff --git a/ruff_cli/src/args.rs b/ruff_cli/src/args.rs index 333a191e0a2d3..eef8f8294027a 100644 --- a/ruff_cli/src/args.rs +++ b/ruff_cli/src/args.rs @@ -211,11 +211,12 @@ pub struct CheckArgs { /// Exit with status code "0", even upon detecting lint violations. #[arg(short, long, help_heading = "Miscellaneous")] pub exit_zero: bool, - /// Enable or disable automatic update checks. + /// Does nothing and will be removed in the future. #[arg( long, overrides_with("no_update_check"), - help_heading = "Miscellaneous" + help_heading = "Miscellaneous", + hide = true )] update_check: bool, #[clap(long, overrides_with("update_check"), hide = true)] diff --git a/ruff_cli/src/main.rs b/ruff_cli/src/main.rs index 597728ccd17ac..b83533eadfe7e 100644 --- a/ruff_cli/src/main.rs +++ b/ruff_cli/src/main.rs @@ -3,17 +3,18 @@ use std::path::PathBuf; use std::process::ExitCode; use std::sync::mpsc::channel; +use anyhow::Result; +use clap::{CommandFactory, Parser, Subcommand}; +use colored::Colorize; +use notify::{recommended_watcher, RecursiveMode, Watcher}; + use ::ruff::logging::{set_up_logging, LogLevel}; use ::ruff::resolver::PyprojectDiscovery; use ::ruff::settings::types::SerializationFormat; +use ::ruff::settings::CliSettings; use ::ruff::{fix, fs, warn_user_once}; -use anyhow::Result; use args::{Args, CheckArgs, Command}; -use clap::{CommandFactory, Parser, Subcommand}; -use colored::Colorize; -use notify::{recommended_watcher, RecursiveMode, Watcher}; use printer::{Printer, Violations}; -use ruff::settings::CliSettings; pub(crate) mod args; mod cache; @@ -22,8 +23,6 @@ mod diagnostics; mod iterators; mod printer; mod resolve; -#[cfg(all(feature = "update-informer"))] -pub mod updates; fn inner_main() -> Result<ExitCode> { let mut args: Vec<_> = std::env::args_os().collect(); @@ -256,14 +255,10 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitCode> { } } - // Check for updates if we're in a non-silent log level. - #[cfg(feature = "update-informer")] - if update_check - && !is_stdin - && log_level >= LogLevel::Default - && atty::is(atty::Stream::Stdout) - { - drop(updates::check_for_updates()); + if update_check { + warn_user_once!( + "update-check has been removed; setting it will cause an error in a future version." + ); } if !cli.exit_zero { diff --git a/ruff_cli/src/updates.rs b/ruff_cli/src/updates.rs deleted file mode 100644 index 621e77e31f38d..0000000000000 --- a/ruff_cli/src/updates.rs +++ /dev/null @@ -1,78 +0,0 @@ -use std::fs::{create_dir_all, read_to_string, File}; -use std::io::Write; -use std::path::{Path, PathBuf}; - -use anyhow::Result; -use colored::Colorize; - -const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME"); -const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); - -fn cache_dir() -> &'static str { - "./.ruff_cache" -} - -fn file_path() -> PathBuf { - Path::new(cache_dir()).join(".update-informer") -} - -/// Get the "latest" version for which the user has been informed. -fn get_latest() -> Result<Option<String>> { - let path = file_path(); - if path.exists() { - Ok(Some(read_to_string(path)?.trim().to_string())) - } else { - Ok(None) - } -} - -/// Set the "latest" version for which the user has been informed. -fn set_latest(version: &str) -> Result<()> { - create_dir_all(cache_dir())?; - let path = file_path(); - let mut file = File::create(path)?; - file.write_all(version.trim().as_bytes())?; - Ok(()) -} - -/// Update the user if a newer version is available. -pub fn check_for_updates() -> Result<()> { - use update_informer::{registry, Check}; - - let informer = update_informer::new(registry::PyPI, CARGO_PKG_NAME, CARGO_PKG_VERSION); - - if let Some(new_version) = informer - .check_version() - .ok() - .flatten() - .map(|version| version.to_string()) - { - // If we've already notified the user about this version, return early. - if let Some(latest_version) = get_latest()? { - if latest_version == new_version { - return Ok(()); - } - } - set_latest(&new_version)?; - - let msg = format!( - "A new version of {pkg_name} is available: v{pkg_version} -> {new_version}", - pkg_name = CARGO_PKG_NAME.italic().cyan(), - pkg_version = CARGO_PKG_VERSION, - new_version = new_version.green() - ); - - let cmd = format!( - "Run to update: {cmd} {pkg_name}", - cmd = "pip3 install --upgrade".green(), - pkg_name = CARGO_PKG_NAME.green() - ); - - #[allow(clippy::print_stdout)] - { - println!("\n{msg}\n{cmd}"); - } - } - - Ok(()) -}