From f9f7a6901bc78f7429c6b2393d747350ac704f33 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Thu, 8 Jan 2026 16:04:34 -0800 Subject: [PATCH] Complete minor TODO in ty_python_semantic crate (#22468) This TODO is very old -- we have long since recorded this definition. Updating the test to actually assert the declaration requires a new helper method for declarations, to complement the existing `first_public_binding` helper. --------- Co-authored-by: Claude --- .../ty_python_semantic/src/semantic_index.rs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/ty_python_semantic/src/semantic_index.rs b/crates/ty_python_semantic/src/semantic_index.rs index 958c7f6915..8642dcf897 100644 --- a/crates/ty_python_semantic/src/semantic_index.rs +++ b/crates/ty_python_semantic/src/semantic_index.rs @@ -781,6 +781,13 @@ mod tests { .find_map(|constrained_binding| constrained_binding.binding.definition()) } + fn first_public_declaration(&self, symbol: ScopedSymbolId) -> Option> { + self.end_of_scope_symbol_declarations(symbol) + .find_map(|declaration_with_constraint| { + declaration_with_constraint.declaration.definition() + }) + } + fn first_binding_at_use(&self, use_id: ScopedUseId) -> Option> { self.bindings_at_use(use_id) .find_map(|constrained_binding| constrained_binding.binding.definition()) @@ -833,10 +840,19 @@ mod tests { #[test] fn annotation_only() { let TestCase { db, file } = test_case("x: int"); - let global_table = place_table(&db, global_scope(&db, file)); + let scope = global_scope(&db, file); + let global_table = place_table(&db, scope); assert_eq!(names(global_table), vec!["int", "x"]); - // TODO record definition + + let use_def = use_def_map(&db, scope); + let declaration = use_def + .first_public_declaration(global_table.symbol_id("x").expect("symbol to exist")) + .unwrap(); + assert!(matches!( + declaration.kind(&db), + DefinitionKind::AnnotatedAssignment(_) + )); } #[test]