The __all__ property of a module is used to define the list of names that will be imported when performing a wildcard import of this
module, i.e. when from mymodule import * is used.
In the following example:
# mymodule.py
def foo(): ...
def bar(): ...
__all__ = ["foo"]
Executing from mymodule import * from a different module will only import foo.
This list can only contain strings. If something other than a string is listed, a TypeError will be raised when trying to perform a
wildcard import of the module.
To fix this issue, make sure that all properties listed in __all__ are strings.
Code examples
Noncompliant code example
class MyClass:
pass
__all__ = [
MyClass # Noncompliant: wildcard import will raise a TypeError
]
Compliant solution
class MyClass:
pass
__all__ = [
"MyClass"
]