From 505dcc81ac1961ed18a25533be29de39c24720be Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Mon, 15 Dec 2025 19:53:06 +0900 Subject: [PATCH] revert unnecessary changes --- crates/ruff_benchmark/benches/ty_walltime.rs | 28 +++++++++---------- crates/ty_python_semantic/src/types.rs | 4 +-- crates/ty_python_semantic/src/types/infer.rs | 15 ---------- .../src/types/infer/builder.rs | 4 +-- .../types/infer/builder/type_expression.rs | 2 +- .../src/types/protocol_class.rs | 2 +- 6 files changed, 19 insertions(+), 36 deletions(-) diff --git a/crates/ruff_benchmark/benches/ty_walltime.rs b/crates/ruff_benchmark/benches/ty_walltime.rs index e92d5295e1..f3ef925e19 100644 --- a/crates/ruff_benchmark/benches/ty_walltime.rs +++ b/crates/ruff_benchmark/benches/ty_walltime.rs @@ -184,21 +184,19 @@ static PYDANTIC: Benchmark = Benchmark::new( 7000, ); -static SYMPY: std::sync::LazyLock> = std::sync::LazyLock::new(|| { - Benchmark::new( - RealWorldProject { - name: "sympy", - repository: "https://github.com/sympy/sympy", - commit: "22fc107a94eaabc4f6eb31470b39db65abb7a394", - paths: &["sympy"], - dependencies: &["mpmath"], - max_dep_date: "2025-06-17", - python_version: PythonVersion::PY312, - }, - // TODO: With better decorator support, `__slots__` support, etc., it should be possible to reduce the number of errors considerably. - 70000, - ) -}); +static SYMPY: Benchmark = Benchmark::new( + RealWorldProject { + name: "sympy", + repository: "https://github.com/sympy/sympy", + commit: "22fc107a94eaabc4f6eb31470b39db65abb7a394", + paths: &["sympy"], + dependencies: &["mpmath"], + max_dep_date: "2025-06-17", + python_version: PythonVersion::PY312, + }, + // TODO: With better decorator support, `__slots__` support, etc., it should be possible to reduce the number of errors considerably. + 70000, +); static TANJUN: Benchmark = Benchmark::new( RealWorldProject { diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index b0f0b93e95..6dfe53611b 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -2,8 +2,6 @@ use compact_str::{CompactString, ToCompactString}; use infer::nearest_enclosing_class; use itertools::{Either, Itertools}; use ruff_diagnostics::{Edit, Fix}; -use ruff_python_ast::name::Name; -use smallvec::{SmallVec, smallvec}; use std::borrow::Cow; use std::time::Duration; @@ -17,7 +15,9 @@ use ruff_db::diagnostic::{Annotation, Diagnostic, Span, SubDiagnostic, SubDiagno use ruff_db::files::File; use ruff_db::parsed::parsed_module; use ruff_python_ast as ast; +use ruff_python_ast::name::Name; use ruff_text_size::{Ranged, TextRange}; +use smallvec::{SmallVec, smallvec}; use type_ordering::union_or_intersection_elements_ordering; diff --git a/crates/ty_python_semantic/src/types/infer.rs b/crates/ty_python_semantic/src/types/infer.rs index 2f83063ed9..e565b84622 100644 --- a/crates/ty_python_semantic/src/types/infer.rs +++ b/crates/ty_python_semantic/src/types/infer.rs @@ -193,7 +193,6 @@ pub(crate) fn infer_expression_types<'db>( infer_expression_types_impl(db, InferExpression::new(db, expression, tcx)) } -/// When using types ​​in [`ExpressionInference`], you must use [`ExpressionInference::cycle_recovery`]. #[salsa::tracked(returns(ref), cycle_fn=expression_cycle_recover, cycle_initial=expression_cycle_initial, heap_size=ruff_memory_usage::heap_size)] pub(super) fn infer_expression_types_impl<'db>( db: &'db dyn Db, @@ -824,13 +823,6 @@ impl<'db> DefinitionInference<'db> { self.extra.as_ref().and_then(|extra| extra.cycle_recovery) } - /// When using `DefinitionInference` during type inference, - /// use this method to get the cycle recovery type so that divergent types are propagated. - #[allow(unused)] - pub(super) fn cycle_recovery(&self) -> Option> { - self.fallback_type() - } - pub(crate) fn undecorated_type(&self) -> Option> { self.extra.as_ref().and_then(|extra| extra.undecorated_type) } @@ -933,13 +925,6 @@ impl<'db> ExpressionInference<'db> { self.extra.as_ref().and_then(|extra| extra.cycle_recovery) } - /// When using `ExpressionInference` during type inference, - /// use this method to get the cycle recovery type so that divergent types are propagated. - #[allow(unused)] - pub(super) fn cycle_recovery(&self) -> Option> { - self.fallback_type() - } - /// Returns true if all places in this expression are definitely bound. pub(crate) fn all_places_definitely_bound(&self) -> bool { self.extra diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index 18c273895e..815a546bf3 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -130,7 +130,7 @@ enum IntersectionOn { } #[derive(Debug, Clone, Copy, Eq, PartialEq)] -pub(super) struct TypeAndRange<'db> { +struct TypeAndRange<'db> { ty: Type<'db>, range: TextRange, } @@ -8432,7 +8432,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { // Special handling for `TypedDict` method calls if let ast::Expr::Attribute(ast::ExprAttribute { value, attr, .. }) = func.as_ref() { - let value_type = self.expression_type(value.as_ref()); + let value_type = self.expression_type(value); if let Type::TypedDict(typed_dict_ty) = value_type { if matches!(attr.id.as_str(), "pop" | "setdefault") && !arguments.args.is_empty() { // Validate the key argument for `TypedDict` methods diff --git a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs index 823dfc0d73..d4c5701f1d 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs @@ -580,7 +580,7 @@ impl<'db> TypeInferenceBuilder<'db, '_> { // we do not store types for sub-expressions. Re-infer the type here. builder.infer_expression(value, TypeContext::default()) } else { - builder.expression_type(value.as_ref()) + builder.expression_type(value) }; value_ty == Type::SpecialForm(SpecialFormType::Unpack) diff --git a/crates/ty_python_semantic/src/types/protocol_class.rs b/crates/ty_python_semantic/src/types/protocol_class.rs index 130055cf3b..5d3719b8d9 100644 --- a/crates/ty_python_semantic/src/types/protocol_class.rs +++ b/crates/ty_python_semantic/src/types/protocol_class.rs @@ -682,7 +682,7 @@ impl<'a, 'db> ProtocolMember<'a, 'db> { self.qualifiers } - pub(super) fn ty(&self) -> Type<'db> { + fn ty(&self) -> Type<'db> { match &self.kind { ProtocolMemberKind::Method(callable) => Type::Callable(*callable), ProtocolMemberKind::Property(property) => Type::PropertyInstance(*property),