Skip to content

inspect.signature fails on compiled functions #838

@twoertwein

Description

@twoertwein

signature.py

import inspect

import compiled

inspect.signature(compiled.fun)

compiled.py

def fun(test: str = "test") -> int:
    return 1
$ mypyc compiled.py
$ python signature.py
Traceback (most recent call last):
  File "/pool01/home/twoertwe/git/python-tools/signature.py", line 5, in <module>
    inspect.signature(compiled.fun)
  File "/home/twoertwe/local/lib/python3.9/inspect.py", line 3130, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/home/twoertwe/local/lib/python3.9/inspect.py", line 2879, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
  File "/home/twoertwe/local/lib/python3.9/inspect.py", line 2334, in _signature_from_callable
    return _signature_from_builtin(sigcls, obj,
  File "/home/twoertwe/local/lib/python3.9/inspect.py", line 2145, in _signature_from_builtin
    raise ValueError("no signature found for builtin {!r}".format(func))
ValueError: no signature found for builtin <built-in function fun>

I encountered this issue when using a compiled function with client.register_worker_callbacks in dask https://docs.dask.org/en/latest/futures.html?highlight=register_worker_callbacks#distributed.Client.register_worker_callbacks

Metadata

Metadata

Assignees

No one assigned

    Labels

    python compatMypyc doesn't match CPython or documented semantics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions