Skip to content

Commit

Permalink
Merge #2929
Browse files Browse the repository at this point in the history
2929: docs: Precise the abscense of `py: Python` for the #[pyo3(signature)] r=davidhewitt a=jjerphan

Hi,

First, thank you for working on PyO3!

I think this adds a precision which was not obvious when migrating to 0.18.0 conventions.

What do you think? Also, should something be added to [the migration guide](https://pyo3.rs/main/migration) in this regard?

Thank you!

Co-authored-by: Julien Jerphanion <[email protected]>
  • Loading branch information
bors[bot] and jjerphan authored Feb 3, 2023
2 parents 806eed5 + 9306d56 commit 4d80475
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions guide/src/function/signature.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ impl MyClass {
}
}
```

Arguments of type `Python` must not be part of the signature:

```rust
# #![allow(dead_code)]
# use pyo3::prelude::*;
#[pyfunction]
#[pyo3(signature = (lambda))]
pub fn simple_python_bound_function(
py: Python<'_>,
lambda: PyObject,
) -> PyResult<()> {
Ok(())
}
```

N.B. the position of the `/` and `*` arguments (if included) control the system of handling positional and keyword arguments. In Python:
```python
import mymodule
Expand Down

0 comments on commit 4d80475

Please sign in to comment.