pyo3 icon indicating copy to clipboard operation
pyo3 copied to clipboard

signature of function doesn't support return value

Open clouds56 opened this issue 8 months ago • 2 comments

I'd like to write code like this, but it doesn't support writing return value now

#[pymethods]
impl MyClass {
  #[pyo3(signature = (x, y, *, abs=true) -> int)]
  fn get(x: i32, y: i32, abs: bool) -> u8 {todo!()}
}

clouds56 avatar May 13 '25 13:05 clouds56

Can you explain your use-case why you want a return value here? If this is for type hinting, see #5137

davidhewitt avatar May 13 '25 14:05 davidhewitt

Yes, I'm looking forward to type hinting.

clouds56 avatar May 13 '25 18:05 clouds56

Implemented in #5241 (however we still need to build a lot of the infrastructure)

davidhewitt avatar Jul 19 '25 09:07 davidhewitt