Skip to content

Commit

Permalink
Renames #[pyo3] to #[pymodule_export]
Browse files Browse the repository at this point in the history
  • Loading branch information
Tpt committed Feb 23, 2024
1 parent e3d6f82 commit cff28c5
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyo3-macros-backend/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn pymodule_module_impl(mut module: syn::ItemMod) -> Result<TokenStream> {
Item::Use(item_use) => {
let mut is_pyo3 = false;
item_use.attrs.retain(|attr| {
let found = attr.path().is_ident("pyo3");
let found = attr.path().is_ident("pymodule_export");
is_pyo3 |= found;
!found
});
Expand Down
5 changes: 3 additions & 2 deletions pytests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use pyo3::prelude::*;

pub mod awaitable;
pub mod buf_and_str;
pub mod comparisons;
Expand All @@ -18,14 +19,14 @@ pub mod subclassing;
mod pyo3_pytests {
use super::*;
use pyo3::types::PyDict;
#[pyo3]
#[pymodule_export]
use {
awaitable::awaitable, comparisons::comparisons, dict_iter::dict_iter, enums::enums,
misc::misc, objstore::objstore, othermod::othermod, path::path, pyclasses::pyclasses,
pyfunctions::pyfunctions, sequence::sequence, subclassing::subclassing,
};
#[cfg(not(Py_LIMITED_API))]
#[pyo3]
#[pymodule_export]
use {buf_and_str::buf_and_str, datetime::datetime};

#[pymodule_init]
Expand Down
3 changes: 2 additions & 1 deletion tests/test_append_to_inittab.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg(all(feature = "macros", not(PyPy)))]

use pyo3::prelude::*;

#[pyfunction]
Expand All @@ -14,7 +15,7 @@ fn module_fn_with_functions(_py: Python<'_>, m: &PyModule) -> PyResult<()> {

#[pymodule]
mod module_mod_with_functions {
#[pyo3]
#[pymodule_export]
use super::foo;
}

Expand Down
10 changes: 5 additions & 5 deletions tests/test_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,14 @@ create_exception!(
/// A module written using declarative syntax.
#[pymodule]
mod declarative_module {
#[pyo3]
#[pymodule_export]
use super::declarative_submodule;
#[pyo3]
#[pymodule_export]
// This is not a real constraint but to test cfg attribute support
#[cfg(not(Py_LIMITED_API))]
use super::LocatedClass;
use super::*;
#[pyo3]
#[pymodule_export]
use super::{declarative_module2, double, MyError, ValueClass as Value};

#[pymodule_init]
Expand All @@ -519,15 +519,15 @@ fn double_value(v: &ValueClass) -> usize {

#[pymodule]
mod declarative_submodule {
#[pyo3]
#[pymodule_export]
use super::{double, double_value};
}

/// A module written using declarative syntax.
#[pymodule]
#[pyo3(name = "declarative_module_renamed")]
mod declarative_module2 {
#[pyo3]
#[pymodule_export]
use super::double;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/invalid_pymodule_glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn foo() -> usize {

#[pymodule]
mod module {
#[pyo3]
#[pymodule_export]
use super::*;
}

Expand Down
Empty file.
2 changes: 1 addition & 1 deletion tests/ui/invalid_pymodule_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use pyo3::prelude::*;

#[pymodule]
mod module {
#[pyo3]
#[pymodule_export]
trait Foo {}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/invalid_pymodule_trait.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: only 'use' statements and and pymodule_init functions are allowed in #[pymodule]
--> tests/ui/invalid_pymodule_trait.rs:5:5
|
5 | #[pyo3]
5 | #[pymodule_export]
| ^

0 comments on commit cff28c5

Please sign in to comment.