Skip to content

Commit

Permalink
Auto-format by https://ultralytics.com
Browse files Browse the repository at this point in the history
  • Loading branch information
UltralyticsAssistant committed Jan 17, 2025
1 parent 49d75cb commit ff60050
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions autoimport/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ def lazy_import(name, globals=None, locals=None, fromlist=(), level=0):
**{from_item: self._lazy_modules[f"{module_name}.{from_item}"] for from_item in fromlist}
)
else:
if "." in name: # we need to only return parent package
module_name = name.split('.')[0]
if "." in name: # we need to only return parent package
module_name = name.split(".")[0]

if globals and module_name in globals:
self._lazy_modules[module_name] = globals[module_name]
elif module_name in sys.modules:
self._lazy_modules[module_name] = sys.modules[module_name] # module already loaded in session
self._lazy_modules[module_name] = sys.modules[module_name] # module already loaded in session
elif module_name not in self._lazy_modules:
self._lazy_modules[module_name] = LazyLoader(module_name)

Expand All @@ -89,6 +89,7 @@ def __exit__(self, *args):
"""Restores the original import mechanism and updates sys.modules with any loaded lazy modules."""
builtins.__import__ = self._original_import


if __name__ == "__main__":
import time

Expand Down

0 comments on commit ff60050

Please sign in to comment.