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

Wildcard import expression should only import items provided in __all__ iterable. #13

Open
albertas opened this issue Jul 11, 2024 · 0 comments

Comments

@albertas
Copy link
Owner

albertas commented Jul 11, 2024

By default wildcard import imports all the names, which do not start with underscore.
However, it is possible to limit names, which might be imported by defining __all__ variable in the module. Only items listed in __all__ variable can be imported from this module.

This should be reflected in the behavior of deadcode.

Example:
foo.py

__all__ = ['foo', 'bar']

foo = 1
bar = 2
spam = 3

bar.py

from foo import *

print(foo)
print(bar)

# Should raise an error, because `spam` was not imported:
print(spam)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant