You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started adding text_signature annotations to my python module, in order to offer better support for IDEs.
When trying to read back my new annotations with inspect.signature(), I got a ValueError. Before adding the text_signature it worked, but only provided the automatically derived information.
Steps to Reproduce
My code:
#[pymethods]structTest{#[pyo3(text_signature = "(self, greet_text: str) -> None")]// <- this is new
fn hello(&self,greet_text:&str){// ...}}
@DanielT is -> None always invalid here or is it only invalid for your use case? If the former, I think we should re-open and aim to fail to compile here.
The return type is always invalid here.
I dug into the CPython source code, and it is looking for a separator pattern between the text signature and the doc comment, and that pattern must end with a ")" on the text signature.
Edit: Additonally, as far as I can tell inspect.signature would be unable to handle the return type while building a Signature object
Bug Description
I started adding text_signature annotations to my python module, in order to offer better support for IDEs.
When trying to read back my new annotations with
inspect.signature()
, I got a ValueError. Before adding the text_signature it worked, but only provided the automatically derived information.Steps to Reproduce
My code:
Before adding the text_signature:
after adding the text_signature:
After some poking around I found that the
__text__signature__
attribute is now missing:This looks like a bug to me.
Backtrace
Your operating system and version
Windows 10
Your Python version (
python --version
)Python 3.13.2
Your Rust version (
rustc --version
)rust 1.85
Your PyO3 version
0.23.4
How did you install python? Did you use a virtualenv?
I'm using a venv, which I re-created before reporting this bug, just to make sure I wasn't chasing an already-fixed bug
Additional Info
No response
The text was updated successfully, but these errors were encountered: