Skip to content

Commit

Permalink
chore: Update pyo3 to 0.22
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <[email protected]>
  • Loading branch information
Stranger6667 committed Aug 24, 2024
1 parent c449e7a commit dba086d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions bindings/python/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Changed

- Update `pyo3` to `0.22`.

## [0.18.0] - 2024-05-07

### Added
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ crate-type = ["cdylib"]

[build-dependencies]
built = { version = "0.7.1", features = ["cargo-lock", "chrono"] }
pyo3-build-config = { version = "0.21.2", features = ["resolve-config"] }
pyo3-build-config = { version = "0.22.2", features = ["resolve-config"] }

[dependencies.jsonschema]
path = "../../jsonschema"
Expand All @@ -28,7 +28,7 @@ features = ["resolve-http", "resolve-file", "draft201909", "draft202012"]
[dependencies]
serde_json = "1.0.91"
serde = "1.0.152"
pyo3 = { version = "0.21.2", features = ["extension-module"] }
pyo3 = { version = "0.22.2", features = ["extension-module"] }
pyo3-built = "0.5"

[profile.release]
Expand Down
18 changes: 9 additions & 9 deletions bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ fn to_error_message(error: &jsonschema::ValidationError<'_>) -> String {
/// If your workflow implies validating against the same schema, consider using `JSONSchema.is_valid`
/// instead.
#[pyfunction]
#[pyo3(text_signature = "(schema, instance, draft=None, with_meta_schemas=False, formats=None)")]
#[pyo3(signature = (schema, instance, draft=None, with_meta_schemas=false, formats=None))]
fn is_valid(
py: Python<'_>,
schema: &Bound<'_, PyAny>,
Expand Down Expand Up @@ -317,7 +317,7 @@ fn is_valid(
/// If your workflow implies validating against the same schema, consider using `JSONSchema.validate`
/// instead.
#[pyfunction]
#[pyo3(text_signature = "(schema, instance, draft=None, with_meta_schemas=False, formats=None)")]
#[pyo3(signature = (schema, instance, draft=None, with_meta_schemas=false, formats=None))]
fn validate(
py: Python<'_>,
schema: &Bound<'_, PyAny>,
Expand Down Expand Up @@ -345,7 +345,7 @@ fn validate(
/// If your workflow implies validating against the same schema, consider using `JSONSchema.iter_errors`
/// instead.
#[pyfunction]
#[pyo3(text_signature = "(schema, instance, draft=None, with_meta_schemas=False, formats=None)")]
#[pyo3(signature = (schema, instance, draft=None, with_meta_schemas=false, formats=None))]
fn iter_errors(
py: Python<'_>,
schema: &Bound<'_, PyAny>,
Expand Down Expand Up @@ -403,16 +403,16 @@ fn handle_format_checked_panic(err: Box<dyn Any + Send>) -> PyErr {
#[pymethods]
impl JSONSchema {
#[new]
#[pyo3(text_signature = "(schema, draft=None, with_meta_schemas=False, formats=None)")]
#[pyo3(signature = (schema, draft=None, with_meta_schemas=false, formats=None))]
fn new(
py: Python<'_>,
pyschema: &Bound<'_, PyAny>,
schema: &Bound<'_, PyAny>,
draft: Option<u8>,
with_meta_schemas: Option<bool>,
formats: Option<&Bound<'_, PyDict>>,
) -> PyResult<Self> {
let options = make_options(draft, with_meta_schemas, formats)?;
let raw_schema = ser::to_value(pyschema)?;
let raw_schema = ser::to_value(schema)?;
match options.compile(&raw_schema) {
Ok(schema) => Ok(JSONSchema {
schema,
Expand All @@ -429,16 +429,16 @@ impl JSONSchema {
///
/// Use it if you have your schema as a string and want to utilize Rust JSON parsing.
#[classmethod]
#[pyo3(text_signature = "(string, draft=None, with_meta_schemas=False, formats=None)")]
#[pyo3(signature = (string, draft=None, with_meta_schemas=false, formats=None))]
fn from_str(
_: &Bound<'_, PyType>,
py: Python<'_>,
pyschema: &Bound<'_, PyAny>,
string: &Bound<'_, PyAny>,
draft: Option<u8>,
with_meta_schemas: Option<bool>,
formats: Option<&Bound<'_, PyDict>>,
) -> PyResult<Self> {
let obj_ptr = pyschema.as_ptr();
let obj_ptr = string.as_ptr();
let object_type = unsafe { pyo3::ffi::Py_TYPE(obj_ptr) };
if unsafe { object_type != types::STR_TYPE } {
let type_name =
Expand Down

0 comments on commit dba086d

Please sign in to comment.