mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-20 04:29:47 +00:00
[ty] Dont provide goto definition for definitions which are not reexported in builtins (#21127)
This commit is contained in:
parent
d38a5292d2
commit
7045898ffa
2 changed files with 18 additions and 0 deletions
|
|
@ -1592,6 +1592,23 @@ a = Test()
|
|||
");
|
||||
}
|
||||
|
||||
/// Regression test for <https://github.com/astral-sh/ty/issues/1451>.
|
||||
/// We must ensure we respect re-import convention for stub files for
|
||||
/// imports in builtins.pyi.
|
||||
#[test]
|
||||
fn goto_definition_unimported_symbol_imported_in_builtins() {
|
||||
let test = CursorTest::builder()
|
||||
.source(
|
||||
"main.py",
|
||||
"
|
||||
Traceb<CURSOR>ackType
|
||||
",
|
||||
)
|
||||
.build();
|
||||
|
||||
assert_snapshot!(test.goto_definition(), @"No goto target found");
|
||||
}
|
||||
|
||||
impl CursorTest {
|
||||
fn goto_definition(&self) -> String {
|
||||
let Some(targets) = goto_definition(&self.db, self.cursor.file, self.cursor.offset)
|
||||
|
|
|
|||
|
|
@ -615,6 +615,7 @@ pub fn definitions_for_name<'db>(
|
|||
};
|
||||
find_symbol_in_scope(db, builtins_scope, name_str)
|
||||
.into_iter()
|
||||
.filter(|def| def.is_reexported(db))
|
||||
.flat_map(|def| {
|
||||
resolve_definition(
|
||||
db,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue