diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index d52b909115..3eac918bdd 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -5632,11 +5632,9 @@ impl<'db> Type<'db> { Type::KnownInstance(known_instance) => match known_instance { KnownInstanceType::TypeAliasType(alias) => Ok(Type::TypeAlias(*alias)), KnownInstanceType::TypeVar(typevar) => { - let module = parsed_module(db, scope_id.file(db)).load(db); let index = semantic_index(db, scope_id.file(db)); Ok(bind_typevar( db, - &module, index, scope_id.file_scope_id(db), typevar_binding_context, @@ -5709,7 +5707,6 @@ impl<'db> Type<'db> { .build()), SpecialFormType::TypingSelf => { - let module = parsed_module(db, scope_id.file(db)).load(db); let index = semantic_index(db, scope_id.file(db)); let Some(class) = nearest_enclosing_class(db, index, scope_id) else { return Err(InvalidTypeExpressionError { @@ -5747,7 +5744,6 @@ impl<'db> Type<'db> { ); Ok(bind_typevar( db, - &module, index, scope_id.file_scope_id(db), typevar_binding_context, diff --git a/crates/ty_python_semantic/src/types/generics.rs b/crates/ty_python_semantic/src/types/generics.rs index c781d4a69e..b73ad66728 100644 --- a/crates/ty_python_semantic/src/types/generics.rs +++ b/crates/ty_python_semantic/src/types/generics.rs @@ -1,7 +1,6 @@ use crate::types::constraints::ConstraintSet; use itertools::Itertools; -use ruff_db::parsed::ParsedModuleRef; use ruff_python_ast as ast; use rustc_hash::FxHashMap; @@ -26,7 +25,6 @@ use crate::{Db, FxOrderSet}; /// scope. fn enclosing_generic_contexts<'db>( db: &'db dyn Db, - module: &ParsedModuleRef, index: &SemanticIndex<'db>, scope: FileScopeId, ) -> impl Iterator> { @@ -34,13 +32,13 @@ fn enclosing_generic_contexts<'db>( .ancestor_scopes(scope) .filter_map(|(_, ancestor_scope)| match ancestor_scope.node() { NodeWithScopeKind::Class(class) => { - let definition = index.expect_single_definition(class.node(module)); + let definition = index.expect_single_definition(class); binding_type(db, definition) .into_class_literal()? .generic_context(db) } NodeWithScopeKind::Function(function) => { - let definition = index.expect_single_definition(function.node(module)); + let definition = index.expect_single_definition(function); infer_definition_types(db, definition) .undecorated_type() .expect("function should have undecorated type") @@ -49,7 +47,7 @@ fn enclosing_generic_contexts<'db>( .generic_context } NodeWithScopeKind::TypeAlias(type_alias) => { - let definition = index.expect_single_definition(type_alias.node(module)); + let definition = index.expect_single_definition(type_alias); binding_type(db, definition) .into_type_alias()? .into_pep_695_type_alias()? @@ -75,7 +73,6 @@ fn enclosing_generic_contexts<'db>( /// bind the typevar with that new binding context. pub(crate) fn bind_typevar<'db>( db: &'db dyn Db, - module: &ParsedModuleRef, index: &SemanticIndex<'db>, containing_scope: FileScopeId, typevar_binding_context: Option>, @@ -86,13 +83,13 @@ pub(crate) fn bind_typevar<'db>( for ((_, inner), (_, outer)) in index.ancestor_scopes(containing_scope).tuple_windows() { if outer.kind().is_class() { if let NodeWithScopeKind::Function(function) = inner.node() { - let definition = index.expect_single_definition(function.node(module)); + let definition = index.expect_single_definition(function); return Some(typevar.with_binding_context(db, definition)); } } } } - enclosing_generic_contexts(db, module, index, containing_scope) + enclosing_generic_contexts(db, index, containing_scope) .find_map(|enclosing_context| enclosing_context.binds_typevar(db, typevar)) .or_else(|| { typevar_binding_context.map(|typevar_binding_context| { diff --git a/crates/ty_python_semantic/src/types/infer/builder.rs b/crates/ty_python_semantic/src/types/infer/builder.rs index f7eb128766..c7b1b5d26e 100644 --- a/crates/ty_python_semantic/src/types/infer/builder.rs +++ b/crates/ty_python_semantic/src/types/infer/builder.rs @@ -8978,7 +8978,6 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { if let Type::KnownInstance(KnownInstanceType::TypeVar(typevar)) = typevar { bind_typevar( self.db(), - self.module(), self.index, self.scope().file_scope_id(self.db()), self.typevar_binding_context,