Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow generic tuple and list calls in __all__ #6247

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@

__all__ = __all__ + multiprocessing.__all__

__all__ = list[str](["Hello", "world"])
5 changes: 3 additions & 2 deletions crates/ruff_python_ast/src/all.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::helpers::map_subscript;
use crate::{self as ast, Constant, Expr, Stmt};
use bitflags::bitflags;

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