mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
Filter private builtins
members from completions
This commit is contained in:
parent
4cf56d7ad4
commit
cb602bf66c
2 changed files with 8 additions and 4 deletions
|
@ -472,6 +472,7 @@ mod tests {
|
|||
",
|
||||
);
|
||||
test.assert_completions_include("filter");
|
||||
test.assert_completions_do_not_include("_T");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -69,12 +69,12 @@ impl<'db> SemanticModel<'db> {
|
|||
return vec![];
|
||||
};
|
||||
let ty = Type::module_literal(self.db, self.file, &module);
|
||||
let builtin = module.is_known(KnownModule::Builtins);
|
||||
crate::types::all_members(self.db, ty)
|
||||
.into_iter()
|
||||
.map(|name| Completion {
|
||||
name,
|
||||
builtin: module.is_known(KnownModule::Builtins),
|
||||
})
|
||||
// Filter out private members from `builtins`
|
||||
.filter(|name| !builtin || !name.starts_with('_'))
|
||||
.map(|name| Completion { name, builtin })
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
@ -142,6 +142,9 @@ pub struct Completion {
|
|||
/// doesn't make it into the LSP response. Instead, we
|
||||
/// use it mainly in tests so that we can write less
|
||||
/// noisy tests.
|
||||
///
|
||||
/// However, we do pre-filter private names from the
|
||||
/// builtin module before construction.
|
||||
pub builtin: bool,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue