mirror of https://github.com/astral-sh/ruff
Respect all `__all__` definitions for docstring visibility (#5052)
## Summary We changed the semantics around `__all__` in #4885, but didn't update the docstring visibility code to match those changes.
This commit is contained in:
parent
099a9152d1
commit
a431dd0368
|
|
@ -5038,21 +5038,26 @@ impl<'a> Checker<'a> {
|
|||
}
|
||||
|
||||
// Compute visibility of all definitions.
|
||||
let exports: Option<Vec<&str>> = {
|
||||
let global_scope = self.semantic_model.global_scope();
|
||||
let exports: Option<&[&str]> = global_scope
|
||||
.get("__all__")
|
||||
global_scope
|
||||
.bindings_for_name("__all__")
|
||||
.map(|binding_id| &self.semantic_model.bindings[binding_id])
|
||||
.and_then(|binding| match &binding.kind {
|
||||
BindingKind::Export(Export { names }) => Some(names.as_slice()),
|
||||
.filter_map(|binding| match &binding.kind {
|
||||
BindingKind::Export(Export { names }) => Some(names.iter().copied()),
|
||||
_ => None,
|
||||
});
|
||||
let definitions = std::mem::take(&mut self.semantic_model.definitions);
|
||||
})
|
||||
.fold(None, |acc, names| {
|
||||
Some(acc.into_iter().flatten().chain(names).collect())
|
||||
})
|
||||
};
|
||||
|
||||
let definitions = std::mem::take(&mut self.semantic_model.definitions);
|
||||
let mut overloaded_name: Option<String> = None;
|
||||
for ContextualizedDefinition {
|
||||
definition,
|
||||
visibility,
|
||||
} in definitions.resolve(exports).iter()
|
||||
} in definitions.resolve(exports.as_deref()).iter()
|
||||
{
|
||||
let docstring = docstrings::extraction::extract_docstring(definition);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue