Skip to content

Commit

Permalink
fix nightly ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Icxolu committed Jul 27, 2024
1 parent 1ca484d commit 31d604b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions guide/src/class.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ For simple cases where a member variable is just read and written with no side e

```rust
# use pyo3::prelude::*;
# #[allow(dead_code)]
#[pyclass]
struct MyClass {
#[pyo3(get, set)]
Expand Down Expand Up @@ -1360,6 +1361,7 @@ The `#[pyclass]` macro expands to roughly the code seen below. The `PyClassImplC
# #[cfg(not(feature = "multiple-pymethods"))] {
# use pyo3::prelude::*;
// Note: the implementation differs slightly with the `multiple-pymethods` feature enabled.
# #[allow(dead_code)]
struct MyClass {
# #[allow(dead_code)]
num: i32,
Expand Down
10 changes: 10 additions & 0 deletions guide/src/class/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ To automatically generate the `__str__` implementation using a `Display` trait i
# use std::fmt::{Display, Formatter};
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
# #[pyclass(str)]
# struct Coordinate {
x: i32,
Expand All @@ -102,6 +103,7 @@ For convenience, a shorthand format string can be passed to `str` as `str="<form
```rust
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
# #[pyclass(str="({x}, {y}, {z})")]
# struct Coordinate {
x: i32,
Expand All @@ -122,6 +124,7 @@ the subclass name. This is typically done in Python code by accessing
# use pyo3::prelude::*;
# use pyo3::types::PyString;
#
# #[allow(dead_code)]
# #[pyclass]
# struct Number(i32);
#
Expand Down Expand Up @@ -150,6 +153,7 @@ use std::hash::{Hash, Hasher};

# use pyo3::prelude::*;
#
# #[allow(dead_code)]
# #[pyclass]
# struct Number(i32);
#
Expand All @@ -170,6 +174,7 @@ method it should not define a `__hash__()` operation either"
```rust
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
#[pyclass(frozen, eq, hash)]
#[derive(PartialEq, Hash)]
struct Number(i32);
Expand Down Expand Up @@ -213,6 +218,7 @@ use pyo3::class::basic::CompareOp;
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
# #[pyclass]
# struct Number(i32);
#
Expand All @@ -239,6 +245,7 @@ use pyo3::class::basic::CompareOp;

# use pyo3::prelude::*;
#
# #[allow(dead_code)]
# #[pyclass]
# struct Number(i32);
#
Expand Down Expand Up @@ -285,6 +292,7 @@ To implement `__eq__` using the Rust [`PartialEq`] trait implementation, the `eq
```rust
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
#[pyclass(eq)]
#[derive(PartialEq)]
struct Number(i32);
Expand All @@ -295,6 +303,7 @@ To implement `__lt__`, `__le__`, `__gt__`, & `__ge__` using the Rust `PartialOrd
```rust
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
#[pyclass(eq, ord)]
#[derive(PartialEq, PartialOrd)]
struct Number(i32);
Expand All @@ -307,6 +316,7 @@ We'll consider `Number` to be `True` if it is nonzero:
```rust
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
# #[pyclass]
# struct Number(i32);
#
Expand Down
1 change: 1 addition & 0 deletions guide/src/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ done with the `crate` attribute:
# use pyo3::prelude::*;
# pub extern crate pyo3;
# mod reexported { pub use ::pyo3; }
# #[allow(dead_code)]
#[pyclass]
#[pyo3(crate = "reexported::pyo3")]
struct MyClass;
Expand Down
1 change: 1 addition & 0 deletions src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub trait ToPyObject {
/// ```rust
/// use pyo3::prelude::*;
///
/// # #[allow(dead_code)]
/// #[pyclass]
/// struct Number {
/// #[pyo3(get, set)]
Expand Down
5 changes: 4 additions & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ macro_rules! pyobject_native_type_named (
#[macro_export]
macro_rules! pyobject_native_static_type_object(
($typeobject:expr) => {
|_py| unsafe { ::std::ptr::addr_of_mut!($typeobject) }
|_py| {
#[allow(unused_unsafe)] // https://github.com/rust-lang/rust/pull/125834
unsafe { ::std::ptr::addr_of_mut!($typeobject) }
}
};
);

Expand Down
2 changes: 1 addition & 1 deletion tests/test_declarative_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl ValueClass {
}

#[pyclass(module = "module")]
struct LocatedClass {}
pub struct LocatedClass {}

#[pyfunction]
fn double(x: usize) -> usize {
Expand Down
1 change: 1 addition & 0 deletions tests/test_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ make_struct_using_macro!(MyBaseClass, "MyClass");
macro_rules! set_extends_via_macro {
($class_name:ident, $base_class:path) => {
// Try and pass a variable into the extends parameter
#[allow(dead_code)]
#[pyclass(extends=$base_class)]
struct $class_name {}
};
Expand Down

0 comments on commit 31d604b

Please sign in to comment.