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
Is there any chance of supporting the pyo3::pyclass(get_all,set_all) syntax for class members (since that does work behind a feature) - or am I doing something wrong?
The text was updated successfully, but these errors were encountered:
Hi @gsleap! I'm not completely sure why it doesn't work when separated like that, but I was able to make it work by combining the macros into one:
#[cfg(feature = "python")]use pyo3_stub_gen::derive::gen_stub_pyclass;#[cfg(feature = "python")]use pyo3::prelude::*;/// This is a struct for our baselines, so callers know the antenna ordering#[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))]#[derive(Clone)]pubstructBaseline{pubant1_index:usize,pubant2_index:usize,}
This results in:
classBaseline:
r""" This is a struct for our baselines, so callers know the antenna ordering """ant1_index: intant2_index: int
It has to be ordered #[cfg_attr(feature = "python", gen_stub_pyclass, pyclass(get_all, set_all))] instead of #[cfg_attr(feature = "python", pyclass(get_all, set_all), gen_stub_pyclass)] to apply correctly as well.
Hi - I have this rust struct:
The generated stub pyi is:
However if I use
#[pyo3(get,set)]
on each attribute like this:it then produces the correct pyi stub output:
Due to this issue, I cannot use that syntax though as I need it to be behind the
python
feature, e.g.Is there any chance of supporting the
pyo3::pyclass(get_all,set_all)
syntax for class members (since that does work behind a feature) - or am I doing something wrong?The text was updated successfully, but these errors were encountered: