Skip to content

Commit 83fe103

Browse files
Allow generic tuple and list calls in __all__ (#6247)
## Summary Allows, e.g., `__all__ = list[str]()`. Closes #6226.
1 parent e08f873 commit 83fe103

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

crates/ruff/resources/test/fixtures/pylint/invalid_all_format.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@
4040

4141
__all__ = __all__ + multiprocessing.__all__
4242

43+
__all__ = list[str](["Hello", "world"])

crates/ruff_python_ast/src/all.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::helpers::map_subscript;
12
use crate::{self as ast, Constant, Expr, Stmt};
23
use bitflags::bitflags;
34

@@ -67,9 +68,9 @@ where
6768
keywords,
6869
..
6970
}) => {
70-
// Allow `tuple()` and `list()` calls.
71+
// Allow `tuple()`, `list()`, and their generic forms, like `list[int]()`.
7172
if keywords.is_empty() && args.len() <= 1 {
72-
if let Expr::Name(ast::ExprName { id, .. }) = func.as_ref() {
73+
if let Expr::Name(ast::ExprName { id, .. }) = map_subscript(func) {
7374
let id = id.as_str();
7475
if matches!(id, "tuple" | "list") && is_builtin(id) {
7576
let [arg] = args.as_slice() else {

0 commit comments

Comments
 (0)