mirror of https://github.com/astral-sh/ruff
Update Rust toolchain to 1.91 (#21179)
This commit is contained in:
parent
a151f9746d
commit
921f409ee8
|
|
@ -370,7 +370,7 @@ pub(crate) fn format_source(
|
||||||
let line_index = LineIndex::from_source_text(unformatted);
|
let line_index = LineIndex::from_source_text(unformatted);
|
||||||
let byte_range = range.to_text_range(unformatted, &line_index);
|
let byte_range = range.to_text_range(unformatted, &line_index);
|
||||||
format_range(unformatted, byte_range, options).map(|formatted_range| {
|
format_range(unformatted, byte_range, options).map(|formatted_range| {
|
||||||
let mut formatted = unformatted.to_string();
|
let mut formatted = unformatted.clone();
|
||||||
formatted.replace_range(
|
formatted.replace_range(
|
||||||
std::ops::Range::<usize>::from(formatted_range.source_range()),
|
std::ops::Range::<usize>::from(formatted_range.source_range()),
|
||||||
formatted_range.as_code(),
|
formatted_range.as_code(),
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ fn generate_set(output: &mut String, set: Set, parents: &mut Vec<Set>) {
|
||||||
generate_set(
|
generate_set(
|
||||||
output,
|
output,
|
||||||
Set::Named {
|
Set::Named {
|
||||||
name: set_name.to_string(),
|
name: set_name.clone(),
|
||||||
set: *sub_set,
|
set: *sub_set,
|
||||||
},
|
},
|
||||||
parents,
|
parents,
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ fn generate_set(output: &mut String, set: Set, parents: &mut Vec<Set>) {
|
||||||
generate_set(
|
generate_set(
|
||||||
output,
|
output,
|
||||||
Set::Named {
|
Set::Named {
|
||||||
name: set_name.to_string(),
|
name: set_name.clone(),
|
||||||
set: *sub_set,
|
set: *sub_set,
|
||||||
},
|
},
|
||||||
parents,
|
parents,
|
||||||
|
|
|
||||||
|
|
@ -1006,7 +1006,7 @@ impl<Context> std::fmt::Debug for Align<'_, Context> {
|
||||||
/// Block indents indent a block of code, such as in a function body, and therefore insert a line
|
/// Block indents indent a block of code, such as in a function body, and therefore insert a line
|
||||||
/// break before and after the content.
|
/// break before and after the content.
|
||||||
///
|
///
|
||||||
/// Doesn't create an indentation if the passed in content is [`FormatElement.is_empty`].
|
/// Doesn't create an indentation if the passed in content is empty.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ pub(crate) fn unconventional_import_alias(
|
||||||
let mut diagnostic = checker.report_diagnostic(
|
let mut diagnostic = checker.report_diagnostic(
|
||||||
UnconventionalImportAlias {
|
UnconventionalImportAlias {
|
||||||
name: qualified_name,
|
name: qualified_name,
|
||||||
asname: expected_alias.to_string(),
|
asname: expected_alias.clone(),
|
||||||
},
|
},
|
||||||
binding.range(),
|
binding.range(),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,17 @@ use ruff_macros::CacheKey;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, CacheKey, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, CacheKey, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||||
|
#[derive(Default)]
|
||||||
pub enum ParametrizeNameType {
|
pub enum ParametrizeNameType {
|
||||||
#[serde(rename = "csv")]
|
#[serde(rename = "csv")]
|
||||||
Csv,
|
Csv,
|
||||||
#[serde(rename = "tuple")]
|
#[serde(rename = "tuple")]
|
||||||
|
#[default]
|
||||||
Tuple,
|
Tuple,
|
||||||
#[serde(rename = "list")]
|
#[serde(rename = "list")]
|
||||||
List,
|
List,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ParametrizeNameType {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::Tuple
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for ParametrizeNameType {
|
impl Display for ParametrizeNameType {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
|
@ -33,19 +29,15 @@ impl Display for ParametrizeNameType {
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, CacheKey, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, CacheKey, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||||
|
#[derive(Default)]
|
||||||
pub enum ParametrizeValuesType {
|
pub enum ParametrizeValuesType {
|
||||||
#[serde(rename = "tuple")]
|
#[serde(rename = "tuple")]
|
||||||
Tuple,
|
Tuple,
|
||||||
#[serde(rename = "list")]
|
#[serde(rename = "list")]
|
||||||
|
#[default]
|
||||||
List,
|
List,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ParametrizeValuesType {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::List
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for ParametrizeValuesType {
|
impl Display for ParametrizeValuesType {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
|
@ -57,19 +49,15 @@ impl Display for ParametrizeValuesType {
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, CacheKey, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, CacheKey, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||||
|
#[derive(Default)]
|
||||||
pub enum ParametrizeValuesRowType {
|
pub enum ParametrizeValuesRowType {
|
||||||
#[serde(rename = "tuple")]
|
#[serde(rename = "tuple")]
|
||||||
|
#[default]
|
||||||
Tuple,
|
Tuple,
|
||||||
#[serde(rename = "list")]
|
#[serde(rename = "list")]
|
||||||
List,
|
List,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ParametrizeValuesRowType {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::Tuple
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for ParametrizeValuesRowType {
|
impl Display for ParametrizeValuesRowType {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,15 @@ use ruff_macros::CacheKey;
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, CacheKey)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, CacheKey)]
|
||||||
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||||
|
#[derive(Default)]
|
||||||
pub enum Quote {
|
pub enum Quote {
|
||||||
/// Use double quotes.
|
/// Use double quotes.
|
||||||
|
#[default]
|
||||||
Double,
|
Double,
|
||||||
/// Use single quotes.
|
/// Use single quotes.
|
||||||
Single,
|
Single,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Quote {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::Double
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ruff_python_ast::str::Quote> for Quote {
|
impl From<ruff_python_ast::str::Quote> for Quote {
|
||||||
fn from(value: ruff_python_ast::str::Quote) -> Self {
|
fn from(value: ruff_python_ast::str::Quote) -> Self {
|
||||||
match value {
|
match value {
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &Checker, stmt: &Stmt) {
|
||||||
|
|
||||||
let mut diagnostic = checker.report_diagnostic(
|
let mut diagnostic = checker.report_diagnostic(
|
||||||
ReimplementedBuiltin {
|
ReimplementedBuiltin {
|
||||||
replacement: contents.to_string(),
|
replacement: contents.clone(),
|
||||||
},
|
},
|
||||||
TextRange::new(stmt.start(), terminal.stmt.end()),
|
TextRange::new(stmt.start(), terminal.stmt.end()),
|
||||||
);
|
);
|
||||||
|
|
@ -212,7 +212,7 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &Checker, stmt: &Stmt) {
|
||||||
|
|
||||||
let mut diagnostic = checker.report_diagnostic(
|
let mut diagnostic = checker.report_diagnostic(
|
||||||
ReimplementedBuiltin {
|
ReimplementedBuiltin {
|
||||||
replacement: contents.to_string(),
|
replacement: contents.clone(),
|
||||||
},
|
},
|
||||||
TextRange::new(stmt.start(), terminal.stmt.end()),
|
TextRange::new(stmt.start(), terminal.stmt.end()),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ pub(crate) fn banned_api<T: Ranged>(checker: &Checker, policy: &NameMatchPolicy,
|
||||||
checker.report_diagnostic(
|
checker.report_diagnostic(
|
||||||
BannedApi {
|
BannedApi {
|
||||||
name: banned_module,
|
name: banned_module,
|
||||||
message: reason.msg.to_string(),
|
message: reason.msg.clone(),
|
||||||
},
|
},
|
||||||
node.range(),
|
node.range(),
|
||||||
);
|
);
|
||||||
|
|
@ -74,8 +74,8 @@ pub(crate) fn banned_attribute_access(checker: &Checker, expr: &Expr) {
|
||||||
{
|
{
|
||||||
checker.report_diagnostic(
|
checker.report_diagnostic(
|
||||||
BannedApi {
|
BannedApi {
|
||||||
name: banned_path.to_string(),
|
name: banned_path.clone(),
|
||||||
message: ban.msg.to_string(),
|
message: ban.msg.clone(),
|
||||||
},
|
},
|
||||||
expr.range(),
|
expr.range(),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -20,21 +20,17 @@ use super::categorize::ImportSection;
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, CacheKey)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, CacheKey)]
|
||||||
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||||
|
#[derive(Default)]
|
||||||
pub enum RelativeImportsOrder {
|
pub enum RelativeImportsOrder {
|
||||||
/// Place "closer" imports (fewer `.` characters, most local) before
|
/// Place "closer" imports (fewer `.` characters, most local) before
|
||||||
/// "further" imports (more `.` characters, least local).
|
/// "further" imports (more `.` characters, least local).
|
||||||
ClosestToFurthest,
|
ClosestToFurthest,
|
||||||
/// Place "further" imports (more `.` characters, least local) imports
|
/// Place "further" imports (more `.` characters, least local) imports
|
||||||
/// before "closer" imports (fewer `.` characters, most local).
|
/// before "closer" imports (fewer `.` characters, most local).
|
||||||
|
#[default]
|
||||||
FurthestToClosest,
|
FurthestToClosest,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RelativeImportsOrder {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::FurthestToClosest
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for RelativeImportsOrder {
|
impl Display for RelativeImportsOrder {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
||||||
|
|
@ -427,7 +427,7 @@ pub(crate) fn literal_comparisons(checker: &Checker, compare: &ast::ExprCompare)
|
||||||
|
|
||||||
for diagnostic in &mut diagnostics {
|
for diagnostic in &mut diagnostics {
|
||||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||||
content.to_string(),
|
content.clone(),
|
||||||
compare.range(),
|
compare.range(),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ pub(crate) fn capitalized(checker: &Checker, docstring: &Docstring) {
|
||||||
let mut diagnostic = checker.report_diagnostic(
|
let mut diagnostic = checker.report_diagnostic(
|
||||||
FirstWordUncapitalized {
|
FirstWordUncapitalized {
|
||||||
first_word: first_word.to_string(),
|
first_word: first_word.to_string(),
|
||||||
capitalized_word: capitalized_word.to_string(),
|
capitalized_word: capitalized_word.clone(),
|
||||||
},
|
},
|
||||||
docstring.range(),
|
docstring.range(),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ pub(crate) fn bit_count(checker: &Checker, call: &ExprCall) {
|
||||||
let mut diagnostic = checker.report_diagnostic(
|
let mut diagnostic = checker.report_diagnostic(
|
||||||
BitCount {
|
BitCount {
|
||||||
existing: SourceCodeSnippet::from_str(literal_text),
|
existing: SourceCodeSnippet::from_str(literal_text),
|
||||||
replacement: SourceCodeSnippet::new(replacement.to_string()),
|
replacement: SourceCodeSnippet::new(replacement.clone()),
|
||||||
},
|
},
|
||||||
call.range(),
|
call.range(),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@ class A: ...
|
||||||
let options = PyFormatOptions::from_source_type(source_type);
|
let options = PyFormatOptions::from_source_type(source_type);
|
||||||
let printed = format_range(&source, TextRange::new(start, end), options).unwrap();
|
let printed = format_range(&source, TextRange::new(start, end), options).unwrap();
|
||||||
|
|
||||||
let mut formatted = source.to_string();
|
let mut formatted = source.clone();
|
||||||
formatted.replace_range(
|
formatted.replace_range(
|
||||||
std::ops::Range::<usize>::from(printed.source_range()),
|
std::ops::Range::<usize>::from(printed.source_range()),
|
||||||
printed.as_code(),
|
printed.as_code(),
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ impl From<String> for PythonPlatform {
|
||||||
fn from(platform: String) -> Self {
|
fn from(platform: String) -> Self {
|
||||||
match platform.as_str() {
|
match platform.as_str() {
|
||||||
"all" => PythonPlatform::All,
|
"all" => PythonPlatform::All,
|
||||||
_ => PythonPlatform::Identifier(platform.to_string()),
|
_ => PythonPlatform::Identifier(platform.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@
|
||||||
//! have two live bindings of `x`: `x = 3` and `x = 4`.
|
//! have two live bindings of `x`: `x = 3` and `x = 4`.
|
||||||
//!
|
//!
|
||||||
//! Another piece of information that the `UseDefMap` needs to provide are reachability constraints.
|
//! Another piece of information that the `UseDefMap` needs to provide are reachability constraints.
|
||||||
//! See [`reachability_constraints.rs`] for more details, in particular how they apply to bindings.
|
//! See `reachability_constraints.rs` for more details, in particular how they apply to bindings.
|
||||||
//!
|
//!
|
||||||
//! The [`UseDefMapBuilder`] itself just exposes methods for taking a snapshot, resetting to a
|
//! The [`UseDefMapBuilder`] itself just exposes methods for taking a snapshot, resetting to a
|
||||||
//! snapshot, and merging a snapshot into the current state. The logic using these methods lives in
|
//! snapshot, and merging a snapshot into the current state. The logic using these methods lives in
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.90"
|
channel = "1.91"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue