We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
importlib.import_module
Describe the bug
importlib.import_module("foo")
import foo
deptry
To Reproduce
Steps to reproduce the behavior:
tests/data/some_dyn_imports.py
from importlib import import_module import_module("polars")
tests/unit/imports/test_extract.py
def test_dyn_import_parser_py() -> None: some_dyn_imports_path = Path("tests/data/some_dyn_imports.py") assert get_imported_modules_from_list_of_files([some_dyn_imports_path]) == { "importlib": [Location(some_dyn_imports_path, line=1, column=1)], "polars": [Location(some_dyn_imports_path, line=3, column=1)], }
Expected behavior
The test should pass in cases where the import argument is specified.
System:
Edit I extended the node visitor to accept nodes of this type, initial version captures
import importlib
importlib.import_module("a")
from importlib import import_module
import_module("b")
from importlib import import_module as im
im("c")
The text was updated successfully, but these errors were encountered:
This would be a great addition to the library. Will gladly accept a pull request for this feature.
Sorry, something went wrong.
My pleasure:
Also added a note in the docs usage page to clarify that this is only for string literals (code search shows this is not uncommon in real code)
Resolved by #782.
Successfully merging a pull request may close this issue.
Describe the bug
importlib.import_module("foo")
rather thanimport foo
deptry
To Reproduce
Steps to reproduce the behavior:
tests/data/some_dyn_imports.py
tests/unit/imports/test_extract.py
:Expected behavior
The test should pass in cases where the import argument is specified.
System:
Edit I extended the node visitor to accept nodes of this type, initial version captures
import importlib
->importlib.import_module("a")
lmmx@709acb8from importlib import import_module
->import_module("b")
lmmx@025df97from importlib import import_module as im
->im("c")
lmmx@73c790aThe text was updated successfully, but these errors were encountered: