#[remove_gen_stub]
Expand description
Do nothing but remove all #[gen_stub(xxx)]
for pyclass
, pymethods
, and pyfunction
.
It is useful to use #[gen_stub(xxx)]
under feature-gating stub-gen.
E.g., only generate .pyi when stub-gen
feature is turned-on:
ⓘ
#[cfg_attr(feature = "stub-gen", pyo3_stub_gen_derive::gen_stub_pymethods)]
#[cfg_attr(not(feature = "stub-gen"), pyo3_stub_gen_derive::remove_gen_stub)]
#[pymethods]
impl A {
#[gen_stub(override_return_type(type_repr="typing_extensions.Self", imports=("typing_extensions")))]
#[new]
pub fn new() -> Self {
Self::default()
}
}
#[cfg(feature = "stub-gen")]
define_stub_info_gatherer!(stub_info);
With Cargo.toml:
[features]
stub-gen = ["dep:pyo3-stub-gen"]
[dependencies]
pyo3-stub-gen = {version = "*", optional = true}
pyo3-stub-gen-derive = "*"