mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 21:25:08 +00:00
Switch to Rust 2024 edition (#18129)
This commit is contained in:
parent
e67b35743a
commit
9ae698fe30
1082 changed files with 4211 additions and 3300 deletions
|
@ -217,11 +217,11 @@ impl From<&Expr> for ResolvedPythonType {
|
|||
) {
|
||||
// Ex) `"Hello" % "world"`
|
||||
(ResolvedPythonType::Atom(PythonType::String), _) => {
|
||||
return ResolvedPythonType::Atom(PythonType::String)
|
||||
return ResolvedPythonType::Atom(PythonType::String);
|
||||
}
|
||||
// Ex) `b"Hello" % b"world"`
|
||||
(ResolvedPythonType::Atom(PythonType::Bytes), _) => {
|
||||
return ResolvedPythonType::Atom(PythonType::Bytes)
|
||||
return ResolvedPythonType::Atom(PythonType::Bytes);
|
||||
}
|
||||
// Ex) `1 % 2`
|
||||
(
|
||||
|
@ -452,7 +452,7 @@ impl NumberLike {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ruff_python_ast::ModExpression;
|
||||
use ruff_python_parser::{parse_expression, Parsed};
|
||||
use ruff_python_parser::{Parsed, parse_expression};
|
||||
|
||||
use crate::analyze::type_inference::{NumberLike, PythonType, ResolvedPythonType};
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use ruff_python_stdlib::typing::{
|
|||
is_typed_dict, is_typed_dict_member,
|
||||
};
|
||||
use ruff_text_size::Ranged;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
|
||||
use crate::analyze::type_inference::{NumberLike, PythonType, ResolvedPythonType};
|
||||
use crate::model::SemanticModel;
|
||||
|
@ -1161,7 +1161,7 @@ pub fn find_binding_value<'a>(binding: &Binding, semantic: &'a SemanticModel) ->
|
|||
Some(Stmt::Assign(ast::StmtAssign { value, targets, .. })) => {
|
||||
return targets
|
||||
.iter()
|
||||
.find_map(|target| match_value(binding, target, value))
|
||||
.find_map(|target| match_value(binding, target, value));
|
||||
}
|
||||
Some(Stmt::AnnAssign(ast::StmtAnnAssign {
|
||||
value: Some(value),
|
||||
|
|
|
@ -4,17 +4,17 @@ use std::ops::{Deref, DerefMut};
|
|||
use bitflags::bitflags;
|
||||
|
||||
use crate::all::DunderAllName;
|
||||
use ruff_index::{newtype_index, IndexSlice, IndexVec};
|
||||
use ruff_index::{IndexSlice, IndexVec, newtype_index};
|
||||
use ruff_python_ast::helpers::extract_handled_exceptions;
|
||||
use ruff_python_ast::name::QualifiedName;
|
||||
use ruff_python_ast::{self as ast, Stmt};
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::ScopeId;
|
||||
use crate::context::ExecutionContext;
|
||||
use crate::model::SemanticModel;
|
||||
use crate::nodes::NodeId;
|
||||
use crate::reference::ResolvedReferenceId;
|
||||
use crate::ScopeId;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Binding<'a> {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::ops::Index;
|
||||
|
||||
use ruff_index::{newtype_index, IndexVec};
|
||||
use ruff_index::{IndexVec, newtype_index};
|
||||
|
||||
/// ID uniquely identifying a branch in a program.
|
||||
///
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use ruff_index::{newtype_index, IndexVec};
|
||||
use ruff_index::{IndexVec, newtype_index};
|
||||
use ruff_python_ast::Stmt;
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
|
||||
/// Returns the control flow graph associated to an array of statements
|
||||
pub fn build_cfg(stmts: &[Stmt]) -> ControlFlowGraph<'_> {
|
||||
|
|
|
@ -208,7 +208,7 @@ impl<'stmt> MermaidGraph<'stmt> for CFGWithSource<'stmt> {
|
|||
return MermaidNode {
|
||||
content: "EXIT".to_string(),
|
||||
shape: MermaidNodeShape::DoubleCircle,
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -5,17 +5,17 @@ use std::fmt::Debug;
|
|||
use std::ops::Deref;
|
||||
use std::path::Path;
|
||||
|
||||
use ruff_index::{newtype_index, IndexSlice, IndexVec};
|
||||
use ruff_index::{IndexSlice, IndexVec, newtype_index};
|
||||
use ruff_python_ast::name::QualifiedName;
|
||||
use ruff_python_ast::{self as ast, Stmt, StmtFunctionDef};
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::SemanticModel;
|
||||
use crate::analyze::visibility::{
|
||||
class_visibility, function_visibility, is_property, method_visibility, module_visibility,
|
||||
Visibility,
|
||||
Visibility, class_visibility, function_visibility, is_property, method_visibility,
|
||||
module_visibility,
|
||||
};
|
||||
use crate::model::all::DunderAllName;
|
||||
use crate::SemanticModel;
|
||||
|
||||
/// Id uniquely identifying a definition in a program.
|
||||
#[newtype_index]
|
||||
|
|
|
@ -8,8 +8,8 @@ use ruff_python_ast::{self as ast, Stmt};
|
|||
use ruff_text_size::{Ranged, TextRange};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use ruff_index::{newtype_index, IndexVec};
|
||||
use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor};
|
||||
use ruff_index::{IndexVec, newtype_index};
|
||||
use ruff_python_ast::statement_visitor::{StatementVisitor, walk_stmt};
|
||||
|
||||
/// Id uniquely identifying the set of global names for a given scope.
|
||||
#[newtype_index]
|
||||
|
|
|
@ -273,7 +273,7 @@ impl schemars::JsonSchema for NameImports {
|
|||
"NameImports".to_string()
|
||||
}
|
||||
|
||||
fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
|
||||
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
|
||||
schemars::schema::SchemaObject {
|
||||
instance_type: Some(schemars::schema::InstanceType::String.into()),
|
||||
..Default::default()
|
||||
|
|
|
@ -8,6 +8,7 @@ use ruff_python_ast::name::{QualifiedName, UnqualifiedName};
|
|||
use ruff_python_ast::{self as ast, Expr, ExprContext, PySourceType, Stmt};
|
||||
use ruff_text_size::{Ranged, TextRange, TextSize};
|
||||
|
||||
use crate::Imported;
|
||||
use crate::binding::{
|
||||
Binding, BindingFlags, BindingId, BindingKind, Bindings, Exceptions, FromImport, Import,
|
||||
SubmoduleImport,
|
||||
|
@ -22,7 +23,6 @@ use crate::reference::{
|
|||
UnresolvedReferenceFlags, UnresolvedReferences,
|
||||
};
|
||||
use crate::scope::{Scope, ScopeId, ScopeKind, Scopes};
|
||||
use crate::Imported;
|
||||
|
||||
pub mod all;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use bitflags::bitflags;
|
||||
|
||||
use ruff_python_ast::{self as ast, helpers::map_subscript, Expr, Stmt};
|
||||
use ruff_python_ast::{self as ast, Expr, Stmt, helpers::map_subscript};
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::SemanticModel;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::ops::Index;
|
||||
|
||||
use ruff_index::{newtype_index, IndexVec};
|
||||
use ruff_index::{IndexVec, newtype_index};
|
||||
use ruff_python_ast::{Expr, Stmt};
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::ops::Deref;
|
|||
|
||||
use bitflags::bitflags;
|
||||
|
||||
use ruff_index::{newtype_index, IndexSlice, IndexVec};
|
||||
use ruff_index::{IndexSlice, IndexVec, newtype_index};
|
||||
use ruff_python_ast::ExprContext;
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use bitflags::bitflags;
|
|||
use ruff_python_ast as ast;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use ruff_index::{newtype_index, Idx, IndexSlice, IndexVec};
|
||||
use ruff_index::{Idx, IndexSlice, IndexVec, newtype_index};
|
||||
|
||||
use crate::binding::BindingId;
|
||||
use crate::globals::GlobalsId;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue