Skip to content

Commit 59d5380

Browse files
Try fixing by only passing globals to get_type_hints
1 parent 1db1dfb commit 59d5380

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

python/egglog/egraph.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,12 @@ def _fn_decl(
704704
# https://docs.astral.sh/ruff/rules/typing-only-standard-library-import/
705705
if "Callable" not in hint_globals:
706706
hint_globals["Callable"] = Callable
707-
708-
hints = get_type_hints(fn, hint_globals, hint_locals)
707+
# Instead of passing both globals and locals, just pass the globals. Otherwise, for some reason forward references
708+
# won't be resolved correctly
709+
# We need this to be false so it returns "__forward_value__" https://github.com/python/cpython/blob/440ed18e08887b958ad50db1b823e692a747b671/Lib/typing.py#L919
710+
# https://github.com/egraphs-good/egglog-python/issues/210
711+
hint_globals.update(hint_locals)
712+
hints = get_type_hints(fn, hint_globals)
709713

710714
params = list(signature(fn).parameters.values())
711715

0 commit comments

Comments
 (0)