Skip to content
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

Require --preview for ruff server #10368

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/ruff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,11 @@ pub struct FormatCommand {
}

#[derive(Clone, Debug, clap::Parser)]
pub struct ServerCommand;
pub struct ServerCommand {
/// Enable preview mode; required for regular operation
#[arg(long)]
pub(crate) preview: bool,
}

#[derive(Debug, Clone, Copy, clap::ValueEnum)]
pub enum HelpFormat {
Expand Down
6 changes: 5 additions & 1 deletion crates/ruff/src/commands/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ use tracing_subscriber::{
};
use tracing_tree::time::Uptime;

pub(crate) fn run_server(log_level: LogLevel) -> Result<ExitStatus> {
pub(crate) fn run_server(preview: bool, log_level: LogLevel) -> Result<ExitStatus> {
if !preview {
tracing::error!("--preview needs to be provided as a command line argument while the server is still unstable.\nFor example: `ruff server --preview`");
return Ok(ExitStatus::Error);
}
let trace_level = if log_level == LogLevel::Verbose {
Level::TRACE
} else {
Expand Down
4 changes: 2 additions & 2 deletions crates/ruff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ fn format(args: FormatCommand, global_options: GlobalConfigArgs) -> Result<ExitS

#[allow(clippy::needless_pass_by_value)] // TODO: remove once we start taking arguments from here
fn server(args: ServerCommand, log_level: LogLevel) -> Result<ExitStatus> {
let ServerCommand {} = args;
commands::server::run_server(log_level)
let ServerCommand { preview } = args;
commands::server::run_server(preview, log_level)
}

pub fn check(args: CheckCommand, global_options: GlobalConfigArgs) -> Result<ExitStatus> {
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ changelog_sections.breaking = "Breaking changes"
changelog_sections.preview = "Preview features"
changelog_sections.rule = "Rule changes"
changelog_sections.formatter = "Formatter"
changelog_sections.server = "Server"
changelog_sections.cli = "CLI"
changelog_sections.configuration = "Configuration"
changelog_sections.bug = "Bug fixes"
Expand Down
Loading