Skip to content

Commit

Permalink
PR 3362 - fix ImportFromModule (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
marklysze authored Sep 13, 2024
1 parent 6712b64 commit af7ea9a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions autogen/coding/func_with_reqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dataclasses import dataclass, field
from importlib.abc import SourceLoader
from textwrap import dedent, indent
from typing import Any, Callable, Generic, List, TypeVar, Union
from typing import Any, Callable, Generic, List, Set, TypeVar, Union

from typing_extensions import ParamSpec

Expand Down Expand Up @@ -165,12 +165,12 @@ def _build_python_functions_file(
funcs: List[Union[FunctionWithRequirements[Any, P], Callable[..., Any], FunctionWithRequirementsStr]]
) -> str:
# First collect all global imports
global_imports = set()
global_imports: Set[str] = set()
for func in funcs:
if isinstance(func, (FunctionWithRequirements, FunctionWithRequirementsStr)):
global_imports.update(func.global_imports)
global_imports.update(map(_import_to_str, func.global_imports))

content = "\n".join(map(_import_to_str, global_imports)) + "\n\n"
content = "\n".join(global_imports) + "\n\n"

for func in funcs:
content += _to_code(func) + "\n\n"
Expand Down

0 comments on commit af7ea9a

Please sign in to comment.