Skip to content

Commit

Permalink
LogicOverhaul: Remove LazyModule and everything associated with it
Browse files Browse the repository at this point in the history
This tool was only put into the public API to support a mechanism for
hiding imports from tracking in certain parts of a library. Ultimately,
that paradigm has proven to be a bad one since those hidden imports can
result in fully invisible dependencies if the primary usage modules only
bring in those deps via the LazyModules. The better solution is just to
carefully manage dependencies to only bring in what's needed.

Signed-off-by: Gabe Goodhart <[email protected]>
  • Loading branch information
gabe-l-hart committed Jul 26, 2022
1 parent 3d53ff5 commit fb0c020
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 114 deletions.
1 change: 0 additions & 1 deletion import_tracker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
from . import setup_tools
from .import_tracker import track_module
from .lazy_import_errors import lazy_import_errors
from .lazy_module import LazyModule
36 changes: 0 additions & 36 deletions import_tracker/lazy_module.py

This file was deleted.

2 changes: 0 additions & 2 deletions test/sample_libs/lazy_module/__init__.py

This file was deleted.

4 changes: 0 additions & 4 deletions test/sample_libs/lazy_module/lazy_deps.py

This file was deleted.

5 changes: 0 additions & 5 deletions test/sample_libs/lazy_module/mod.py

This file was deleted.

24 changes: 0 additions & 24 deletions test/test_import_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def test_import_tracker_public_api():
expected_attrs = {
"setup_tools",
"track_module",
"LazyModule",
"lazy_import_errors",
}
module_attrs = set(dir(import_tracker))
Expand Down Expand Up @@ -304,29 +303,6 @@ def test_detect_transitive_with_nested_module_full_depth():
}


def test_lazy_module_trigger():
"""Make sure that a sub-module which holds LazyModule attrs does not
incorrectly trigger their imports when run through import_tracker.
BREAKING CHANGE: With the overhaul to use bytecode, lazy deps are fully
invisible since there's no way to detect when a LazyModule triggers its
import without inspecting every __getattr__ invocation in the bytecode!
This is a departure from the results when instrumenting the import
framework where these changes can be detected in sys.modules.
Ultimately, this functionality with LazyModule should probably go away
fully since it's not a particularly userful tool anymore.
"""
lib_mapping = track_module(
"lazy_module",
submodules=True,
)
assert lib_mapping == {
"lazy_module": [],
"lazy_module.lazy_deps": [],
"lazy_module.mod": [],
}


def test_all_import_types():
"""Make sure that all different import statement types are covered"""
assert track_module("all_import_types", submodules=True) == {
Expand Down
42 changes: 0 additions & 42 deletions test/test_lazy_module.py

This file was deleted.

0 comments on commit fb0c020

Please sign in to comment.