fix some nightly lints 2024-01-12
This commit is contained in:
parent
4b172874dc
commit
4504a7c96e
|
@ -80,6 +80,7 @@ To declare a constructor, you need to define a method and annotate it with the `
|
|||
attribute. Only Python's `__new__` method can be specified, `__init__` is not available.
|
||||
|
||||
```rust
|
||||
# #![allow(dead_code)]
|
||||
# use pyo3::prelude::*;
|
||||
# #[pyclass]
|
||||
# struct Number(i32);
|
||||
|
@ -96,6 +97,7 @@ impl Number {
|
|||
Alternatively, if your `new` method may fail you can return `PyResult<Self>`.
|
||||
|
||||
```rust
|
||||
# #![allow(dead_code)]
|
||||
# use pyo3::prelude::*;
|
||||
# use pyo3::exceptions::PyValueError;
|
||||
# #[pyclass]
|
||||
|
@ -130,6 +132,7 @@ For arguments, see the [`Method arguments`](#method-arguments) section below.
|
|||
The next step is to create the module initializer and add our class to it:
|
||||
|
||||
```rust
|
||||
# #![allow(dead_code)]
|
||||
# use pyo3::prelude::*;
|
||||
# #[pyclass]
|
||||
# struct Number(i32);
|
||||
|
@ -663,6 +666,7 @@ Declares a class method callable from Python.
|
|||
|
||||
To create a constructor which takes a positional class argument, you can combine the `#[classmethod]` and `#[new]` modifiers:
|
||||
```rust
|
||||
# #![allow(dead_code)]
|
||||
# use pyo3::prelude::*;
|
||||
# use pyo3::types::PyType;
|
||||
# #[pyclass]
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
Recall the `Number` class from the previous chapter:
|
||||
|
||||
```rust
|
||||
# #![allow(dead_code)]
|
||||
use pyo3::prelude::*;
|
||||
|
||||
#[pyclass]
|
||||
|
|
|
@ -885,13 +885,10 @@ impl<'a> PyClassImplsBuilder<'a> {
|
|||
let cls = self.cls;
|
||||
let doc = self.doc.as_ref().map_or(quote! {"\0"}, |doc| quote! {#doc});
|
||||
let is_basetype = self.attr.options.subclass.is_some();
|
||||
let base = self
|
||||
.attr
|
||||
.options
|
||||
.extends
|
||||
.as_ref()
|
||||
.map(|extends_attr| extends_attr.value.clone())
|
||||
.unwrap_or_else(|| parse_quote! { _pyo3::PyAny });
|
||||
let base = match &self.attr.options.extends {
|
||||
Some(extends_attr) => extends_attr.value.clone(),
|
||||
None => parse_quote! { _pyo3::PyAny },
|
||||
};
|
||||
let is_subclass = self.attr.options.extends.is_some();
|
||||
let is_mapping: bool = self.attr.options.mapping.is_some();
|
||||
let is_sequence: bool = self.attr.options.sequence.is_some();
|
||||
|
|
|
@ -146,9 +146,10 @@ pub fn unwrap_ty_group(mut ty: &syn::Type) -> &syn::Type {
|
|||
|
||||
/// Extract the path to the pyo3 crate, or use the default (`::pyo3`).
|
||||
pub(crate) fn get_pyo3_crate(attr: &Option<CrateAttribute>) -> syn::Path {
|
||||
attr.as_ref()
|
||||
.map(|p| p.value.0.clone())
|
||||
.unwrap_or_else(|| syn::parse_str("::pyo3").unwrap())
|
||||
match attr {
|
||||
Some(attr) => attr.value.0.clone(),
|
||||
None => syn::parse_str("::pyo3").unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn apply_renaming_rule(rule: RenamingRule, name: &str) -> String {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#[derive(crate::FromPyObject)]
|
||||
#[pyo3(crate = "crate")]
|
||||
struct Derive1(i32); // newtype case
|
||||
struct Derive1(#[allow(dead_code)] i32); // newtype case
|
||||
|
||||
#[derive(crate::FromPyObject)]
|
||||
#[pyo3(crate = "crate")]
|
||||
|
|
|
@ -420,6 +420,7 @@ TypeError: failed to extract enum Foo ('TupleVar | StructVar | TransparentTuple
|
|||
|
||||
#[derive(Debug, FromPyObject)]
|
||||
enum EnumWithCatchAll<'a> {
|
||||
#[allow(dead_code)]
|
||||
#[pyo3(transparent)]
|
||||
Foo(Foo<'a>),
|
||||
#[pyo3(transparent)]
|
||||
|
|
Loading…
Reference in New Issue