Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions python/egglog/egraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,12 @@ def _fn_decl(
# https://docs.astral.sh/ruff/rules/typing-only-standard-library-import/
if "Callable" not in hint_globals:
hint_globals["Callable"] = Callable

hints = get_type_hints(fn, hint_globals, hint_locals)
# Instead of passing both globals and locals, just pass the globals. Otherwise, for some reason forward references
# won't be resolved correctly
# We need this to be false so it returns "__forward_value__" https://github.com/python/cpython/blob/440ed18e08887b958ad50db1b823e692a747b671/Lib/typing.py#L919
# https://github.com/egraphs-good/egglog-python/issues/210
hint_globals.update(hint_locals)
hints = get_type_hints(fn, hint_globals)

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

Expand Down
12 changes: 12 additions & 0 deletions python/tests/test_no_import_star.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import egglog as el


def test_no_import_star():
"""
https://github.com/egraphs-good/egglog-python/issues/210
"""

class Num(el.Expr):
def __init__(self, value: el.i64Like) -> None: ...

Num(1) # gets an error "NameError: name 'i64' is not defined"
Loading