From 9306d56b275bd3c04d77bb0538438d31b17a4739 Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Sun, 29 Jan 2023 21:11:04 +0100 Subject: [PATCH] docs: Precise the abscense of `py: Python` for the #[pyo3(signature)] --- guide/src/function/signature.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/guide/src/function/signature.md b/guide/src/function/signature.md index 651b4a3fc71..d8420ae4813 100644 --- a/guide/src/function/signature.md +++ b/guide/src/function/signature.md @@ -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