Skip to content
New issue

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

fix ImportFromModule is unhashable issue #3362

Merged
8 changes: 4 additions & 4 deletions autogen/coding/func_with_reqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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, TypeVar, Union, Set

from typing_extensions import ParamSpec

Expand Down Expand Up @@ -159,12 +159,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
Loading