Skip to content

Commit

Permalink
Quick-and-dirty upgrade to the latest PyO3 version. (#666)
Browse files Browse the repository at this point in the history
Will clean up more in subsequent commits.
  • Loading branch information
obi1kenobi authored Sep 18, 2024
1 parent 24e6306 commit f86c690
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 132 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pytrustfall/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
async-graphql-parser = { workspace = true }
async-graphql-value = { workspace = true }
pyo3 = { version = "0.20.0", features = ["extension-module"] }
pyo3 = { version = "0.22.0", features = ["extension-module"] }
trustfall_core = { path = "../trustfall_core" }
20 changes: 12 additions & 8 deletions pytrustfall/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use pyo3::{create_exception, types::PyModule, PyResult, Python};
use pyo3::{
create_exception,
types::{PyModule, PyModuleMethods},
Bound, PyResult, Python,
};

create_exception!(pytrustfall, InvalidSchemaError, pyo3::exceptions::PyException);
create_exception!(pytrustfall, ParseError, pyo3::exceptions::PyException);
Expand All @@ -7,12 +11,12 @@ create_exception!(pytrustfall, FrontendError, pyo3::exceptions::PyException);
create_exception!(pytrustfall, InvalidIRQueryError, pyo3::exceptions::PyException);
create_exception!(pytrustfall, QueryArgumentsError, pyo3::exceptions::PyException);

pub(crate) fn register(py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add("InvalidSchemaError", py.get_type::<InvalidSchemaError>())?;
m.add("ParseError", py.get_type::<ParseError>())?;
m.add("ValidationError", py.get_type::<ValidationError>())?;
m.add("FrontendError", py.get_type::<FrontendError>())?;
m.add("InvalidIRQueryError", py.get_type::<InvalidIRQueryError>())?;
m.add("QueryArgumentsError", py.get_type::<QueryArgumentsError>())?;
pub(crate) fn register(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add("InvalidSchemaError", py.get_type_bound::<InvalidSchemaError>())?;
m.add("ParseError", py.get_type_bound::<ParseError>())?;
m.add("ValidationError", py.get_type_bound::<ValidationError>())?;
m.add("FrontendError", py.get_type_bound::<FrontendError>())?;
m.add("InvalidIRQueryError", py.get_type_bound::<InvalidIRQueryError>())?;
m.add("QueryArgumentsError", py.get_type_bound::<QueryArgumentsError>())?;
Ok(())
}
5 changes: 3 additions & 2 deletions pytrustfall/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#![forbid(unused_lifetimes)]
#![forbid(elided_lifetimes_in_paths)]

use pyo3::{pymodule, types::PyModule, PyResult, Python};
use pyo3::{pymodule, types::PyModule, Bound, PyResult, Python};

pub mod errors;
pub mod shim;
mod value;

#[pymodule]
fn trustfall(py: Python<'_>, m: &PyModule) -> PyResult<()> {
fn trustfall(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
shim::register(py, m)?;
errors::register(py, m)?;
Ok(())
Expand Down
Loading

0 comments on commit f86c690

Please sign in to comment.