Python: Handle __all__ assigned to a tuple

Examples where this is used in real code:

- 76c0b32f82/django/core/files/temp.py (L24)
- 76c0b32f82/django/contrib/gis/gdal/__init__.py (L44-L49)
This commit is contained in:
Rasmus Wriedt Larsen
2021-03-31 17:25:19 +02:00
parent 43306f4700
commit ab3edf37d7
2 changed files with 7 additions and 1 deletions

View File

@@ -129,7 +129,11 @@ class Module extends Module_, Scope, AstNode {
a.defines(all) and
a.getScope() = this and
all.getId() = "__all__" and
a.getValue().(List).getAnElt().(StrConst).getText() = name
(
a.getValue().(List).getAnElt().(StrConst).getText() = name
or
a.getValue().(Tuple).getAnElt().(StrConst).getText() = name
)
)
}

View File

@@ -1,3 +1,5 @@
| all_dynamic.py:0:0:0:0 | Module all_dynamic | foo |
| all_list.py:0:0:0:0 | Module all_list | bar |
| all_list.py:0:0:0:0 | Module all_list | foo |
| all_tuple.py:0:0:0:0 | Module all_tuple | bar |
| all_tuple.py:0:0:0:0 | Module all_tuple | foo |