Open jymchng opened 1 year ago
I took a brief look at this, and my conclusion is that __call__
for a native type like in PyO3 isn't currently supported by inspect
.
The error comes from: https://github.com/python/cpython/blob/d01cf5072be5511595b6d0c35ace6c1b07716f8d/Lib/inspect.py#L2616
None of the options supported by that method seem applicable for the __call__
method. I think this probably needs upstream support.
Hi @davidhewitt, thank you for spending your time and looking at this issue.
Can I ask what do you mean by upstream
? Do you mean pyo3
or is there a dependency to which I should raise this issue to?
👍😂
"upstream" in this case would the Python interpreter itself, i.e. CPython at https://github.com/python/cpython
I implemented the is not supported by signature'"
PyNRICContainer
struct in Rust with the following methods__iter__
,__next__
and__call__
. I have also annotatedPyNRICContainer
with the#[pyo3(text_signature=...)]
macro with an appropriatetext_signature
. The__call__
method is not allowed to have atext_signature
annotation but I annotated it with a#[pyo3(signature=...)]
annotation. The error I got from passing the callable object into the functionsignature
of theinspect
module (i.e.inspect.signature(pycallableobj)
) is aValueError
that reads ''callableHere are the codes:
My question is, how to make callable objects compatible with the
inspect.signature
function? Or rather, is there a way to force the__call__
method implemented in rust to have atext_signature
?