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

jaxtyping v0.2.29 now wraps functions without annotations as well. That changes some tracebacks slightly. #742

Merged
merged 2 commits into from
Jun 7, 2024
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
6 changes: 6 additions & 0 deletions equinox/_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,12 @@ def __wrapped__(self):
self.__self__, type(self.__self__)
)

# This should be unnecessary in principle. In practice something goes wrong on
# Python 3.9 and it returns the wrong thing.
@property
def __signature__(self):
return inspect.signature(self.__wrapped__)


#
# Part 3: some downstream pieces. These don't actually affect the core `Module`
Expand Down
15 changes: 10 additions & 5 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ def g(x):
tb = e.__traceback__
code_stack = []
while tb is not None:
code_stack.append(tb.tb_frame.f_code)
if not tb.tb_frame.f_globals["__name__"].startswith("jaxtyping"):
code_stack.append(tb.tb_frame.f_code)
tb = tb.tb_next
assert len(code_stack) == 1
assert code_stack[0].co_filename.endswith("test_errors.py")
assert code_stack[0].co_name == "test_traceback_runtime_eqx"
assert len(code_stack) == 2
one, two = code_stack
assert one.co_filename.endswith("test_errors.py")
assert one.co_name == "test_traceback_runtime_eqx"
assert two.co_filename.endswith("equinox/_jit.py")
assert two.co_name == "_call"


def test_traceback_runtime_custom():
Expand All @@ -177,7 +181,8 @@ def _raises():
tb = e.__traceback__
code_stack = []
while tb is not None:
code_stack.append(tb.tb_frame.f_code)
if not tb.tb_frame.f_globals["__name__"].startswith("jaxtyping"):
code_stack.append(tb.tb_frame.f_code)
tb = tb.tb_next
assert len(code_stack) == 4
one, two, three, four = code_stack
Expand Down
Loading