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 <noreply@anthropic.com>
This commit is contained in:
Carl Meyer
2026-01-08 16:04:34 -08:00
committed by GitHub
parent c920cf8cdb
commit f9f7a6901b

View File

@@ -781,6 +781,13 @@ mod tests {
.find_map(|constrained_binding| constrained_binding.binding.definition())
}
fn first_public_declaration(&self, symbol: ScopedSymbolId) -> Option<Definition<'_>> {
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<Definition<'_>> {
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]