Allow re-assignments to __all__ (#4967)

This commit is contained in:
Charlie Marsh 2023-06-08 13:19:56 -04:00 committed by GitHub
parent 902c4e7d77
commit 58d08219e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 2 deletions

View file

@ -45,11 +45,23 @@ where
// Allow comprehensions, even though we can't statically analyze them.
return (None, AllNamesFlags::empty());
}
Expr::Name(ast::ExprName { id, .. }) => {
// Ex) `__all__ = __all__ + multiprocessing.__all__`
if id == "__all__" {
return (None, AllNamesFlags::empty());
}
}
Expr::Attribute(ast::ExprAttribute { attr, .. }) => {
// Ex) `__all__ = __all__ + multiprocessing.__all__`
if attr == "__all__" {
return (None, AllNamesFlags::empty());
}
}
Expr::Call(ast::ExprCall {
func,
args,
keywords,
range: _range,
..
}) => {
// Allow `tuple()` and `list()` calls.
if keywords.is_empty() && args.len() <= 1 {