Skip to content

Commit

Permalink
fix: Use whole cell when storing source for functions in jupyter (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-koch authored Oct 29, 2024
1 parent 8134a85 commit 735020a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion guppylang/definition/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,13 @@ def parse_py_func(f: PyFunc, sources: SourceMap) -> tuple[ast.FunctionDef, str |
defn = find_ipython_def(func_ast.name)
if defn is not None:
file = f"<{defn.cell_name}>"
sources.add_file(file, source)
sources.add_file(file, defn.cell_source)
else:
# If we couldn't find the defining cell, just use the source code we
# got from inspect. Line numbers will be wrong, but that's the best we
# can do.
sources.add_file(file, source)
line_offset = 1
else:
file = inspect.getsourcefile(f)
if file is None:
Expand Down

0 comments on commit 735020a

Please sign in to comment.