Skip to content

Commit

Permalink
Fix lazy loading of variables
Browse files Browse the repository at this point in the history
This PR fixes lazy imports which broke because the `mang` variable
started with `from` instead of the module name causing the imports to
not be resolved by the `module_dict`
  • Loading branch information
Divyansh Choudhary committed Dec 5, 2024
1 parent 78225b3 commit 66f247a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/python/pyflyby/_dynimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ def _add_import(ip, names: str, code: str) -> None:
private version of add_import
"""
assert ip is not None
mang = PYFLYBY_LAZY_LOAD_PREFIX + names.replace(",", "_").replace(" ", "_")
a: FrozenSet[Import] = ImportSet(f"{mang} import {names}")._importset
module = PYFLYBY_LAZY_LOAD_PREFIX.split(" ")[1]
mang = module + names.replace(",", "_").replace(" ", "_")
a: FrozenSet[Import] = ImportSet(f"from {mang} import {names}")._importset
b: FrozenSet[Import] = ip._auto_importer.db.known_imports._importset
s_import: FrozenSet[Import] = a | b

Expand Down

0 comments on commit 66f247a

Please sign in to comment.