From 5d992b8c8b92c09f4baa9e5ac51ff8cf93191093 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Mon, 24 Jun 2024 14:35:15 +0100 Subject: [PATCH 1/8] update to PyO3 0.22 --- Cargo.lock | 167 +++--------------- Cargo.toml | 13 +- src/argument_markers.rs | 1 + src/errors/types.rs | 4 +- src/errors/value_exception.rs | 10 +- src/input/input_python.rs | 7 +- src/input/return_enums.rs | 8 +- src/lookup_key.rs | 2 +- src/serializers/errors.rs | 1 + src/serializers/extra.rs | 4 +- src/serializers/mod.rs | 1 + src/serializers/type_serializers/dataclass.rs | 6 +- src/serializers/type_serializers/function.rs | 1 + src/validators/dataclass.rs | 10 +- src/validators/datetime.rs | 4 +- src/validators/decimal.rs | 3 +- src/validators/enum_.rs | 5 +- src/validators/function.rs | 6 +- src/validators/is_instance.rs | 2 +- src/validators/is_subclass.rs | 2 +- src/validators/mod.rs | 1 + src/validators/url.rs | 2 +- src/validators/uuid.rs | 5 +- 23 files changed, 85 insertions(+), 180 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c4f6d67e0..5998a79e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,12 +36,6 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitvec" version = "1.0.1" @@ -122,6 +116,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "idna" version = "0.5.0" @@ -156,9 +156,8 @@ checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" [[package]] name = "jiter" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abbbbe1bad457e3cd5503af716aedc735e849505a0d2172c55a753ae1b127458" +version = "0.4.2" +source = "git+https://github.com/pydantic/jiter?branch=dh/pyo3-0.22#e1b18fec7d4e0d7747f9767a50874bcbe00468e0" dependencies = [ "ahash", "bitvec", @@ -206,16 +205,6 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" -[[package]] -name = "lock_api" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "memchr" version = "2.6.3" @@ -267,29 +256,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -304,9 +270,9 @@ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -338,16 +304,15 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" +version = "0.22.0" +source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#f846a6eae4c60c632508e9b645572f340d231900" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", "num-bigint", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -357,9 +322,8 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" +version = "0.22.0" +source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#f846a6eae4c60c632508e9b645572f340d231900" dependencies = [ "once_cell", "python3-dll-a", @@ -368,9 +332,8 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" +version = "0.22.0" +source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#f846a6eae4c60c632508e9b645572f340d231900" dependencies = [ "libc", "pyo3-build-config", @@ -378,9 +341,8 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" +version = "0.22.0" +source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#f846a6eae4c60c632508e9b645572f340d231900" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -390,11 +352,10 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" +version = "0.22.0" +source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#f846a6eae4c60c632508e9b645572f340d231900" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "pyo3-build-config", "quote", @@ -425,15 +386,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags", -] - [[package]] name = "regex" version = "1.10.4" @@ -475,12 +427,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[package]] name = "serde" version = "1.0.203" @@ -550,7 +496,7 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -563,7 +509,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -572,9 +518,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ "proc-macro2", "quote", @@ -589,9 +535,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.9" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df8e77cb757a61f51b947ec4a7e3646efd825b73561db1c232a8ccb639e611a0" +checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "tinyvec" @@ -664,63 +610,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "windows-targets" -version = "0.48.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 7c4614f3c..c03944c60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,9 @@ include = [ rust-version = "1.75" [dependencies] -pyo3 = { version = "0.21.2", features = ["generate-import-lib", "num-bigint"] } +# TODO it would be very nice to remove the "py-clone" feature as it can panic, +# but needs a bit of work to make sure it's not used in the codebase +pyo3 = { version = "0.22.0", features = ["generate-import-lib", "num-bigint", "py-clone"] } regex = "1.10.4" strum = { version = "0.25.0", features = ["derive"] } strum_macros = "0.26.1" @@ -71,12 +73,12 @@ debug = true strip = false [dev-dependencies] -pyo3 = { version = "0.21.2", features = ["auto-initialize"] } +pyo3 = { version = "0.22.0", features = ["auto-initialize"] } [build-dependencies] version_check = "0.9.4" # used where logic has to be version/distribution specific, e.g. pypy -pyo3-build-config = { version = "0.21.0" } +pyo3-build-config = { version = "0.22.0" } [lints.clippy] dbg_macro = "warn" @@ -108,3 +110,8 @@ too_many_lines = "allow" unnecessary_wraps = "allow" unused_self = "allow" used_underscore_binding = "allow" + +[patch.crates-io] +pyo3 = { git = "https://github.com/pyo3/pyo3", branch = "release-0.22" } +pyo3-build-config = { git = "https://github.com/pyo3/pyo3", branch = "release-0.22" } +jiter = { git = "https://github.com/pydantic/jiter", branch = "dh/pyo3-0.22" } diff --git a/src/argument_markers.rs b/src/argument_markers.rs index 4a9e80bbd..23cd74f41 100644 --- a/src/argument_markers.rs +++ b/src/argument_markers.rs @@ -30,6 +30,7 @@ impl ArgsKwargs { #[pymethods] impl ArgsKwargs { #[new] + #[pyo3(signature = (args, kwargs = None))] fn py_new(py: Python, args: &Bound<'_, PyTuple>, kwargs: Option<&Bound<'_, PyDict>>) -> Self { Self { args: args.into_py(py), diff --git a/src/errors/types.rs b/src/errors/types.rs index 57025f9b5..09ad47f38 100644 --- a/src/errors/types.rs +++ b/src/errors/types.rs @@ -459,8 +459,8 @@ static ERROR_TYPE_LOOKUP: GILOnceCell> = GILOnceCell impl ErrorType { pub fn new_custom_error(py: Python, custom_error: PydanticCustomError) -> Self { Self::CustomError { - error_type: custom_error.error_type(), - message_template: custom_error.message_template(), + error_type: custom_error.error_type().to_owned(), + message_template: custom_error.message_template().to_owned(), context: custom_error.context(py), } } diff --git a/src/errors/value_exception.rs b/src/errors/value_exception.rs index 20ad6174a..793bcd0b5 100644 --- a/src/errors/value_exception.rs +++ b/src/errors/value_exception.rs @@ -65,6 +65,7 @@ pub struct PydanticCustomError { #[pymethods] impl PydanticCustomError { #[new] + #[pyo3(signature = (error_type, message_template, context = None))] pub fn py_new(error_type: String, message_template: String, context: Option>) -> Self { Self { error_type, @@ -74,13 +75,13 @@ impl PydanticCustomError { } #[getter(r#type)] - pub fn error_type(&self) -> String { - self.error_type.clone() + pub fn error_type(&self) -> &str { + &self.error_type } #[getter] - pub fn message_template(&self) -> String { - self.message_template.clone() + pub fn message_template(&self) -> &str { + &self.message_template } #[getter] @@ -143,6 +144,7 @@ pub struct PydanticKnownError { #[pymethods] impl PydanticKnownError { #[new] + #[pyo3(signature = (error_type, context=None))] pub fn py_new(py: Python, error_type: &str, context: Option>) -> PyResult { let error_type = ErrorType::new(py, error_type, context)?; Ok(Self { error_type }) diff --git a/src/input/input_python.rs b/src/input/input_python.rs index 2a06228e1..3de712272 100644 --- a/src/input/input_python.rs +++ b/src/input/input_python.rs @@ -318,7 +318,10 @@ impl<'py> Input<'py> for Bound<'py, PyAny> { Err(ValError::new( ErrorType::IsInstanceOf { - class: decimal_type.qualname().unwrap_or_else(|_| "Decimal".to_owned()), + class: decimal_type + .qualname() + .and_then(|name| name.extract()) + .unwrap_or_else(|_| "Decimal".to_owned()), context: None, }, self, @@ -772,7 +775,7 @@ impl<'py> ValidatedDict<'py> for GenericPyMapping<'_, 'py> { match self { Self::Dict(dict) => Ok(consumer.consume_iterator(dict.iter().map(Ok))), Self::Mapping(mapping) => Ok(consumer.consume_iterator(iterate_mapping_items(mapping)?)), - Self::GetAttr(obj, _) => Ok(consumer.consume_iterator(iterate_attributes(obj))), + Self::GetAttr(obj, _) => Ok(consumer.consume_iterator(iterate_attributes(obj)?)), } } } diff --git a/src/input/return_enums.rs b/src/input/return_enums.rs index 22faaba71..8da9dd3e9 100644 --- a/src/input/return_enums.rs +++ b/src/input/return_enums.rs @@ -284,10 +284,10 @@ const MAPPING_TUPLE_ERROR: &str = "Mapping items must be tuples of (key, value) /// Iterate over attributes of an object pub(crate) fn iterate_attributes<'a, 'py>( object: &'a Bound<'py, PyAny>, -) -> impl Iterator, Bound<'py, PyAny>)>> + 'a { - let mut attributes_iterator = object.dir().into_iter(); +) -> PyResult, Bound<'py, PyAny>)>> + 'a> { + let mut attributes_iterator = object.dir()?.into_iter(); - std::iter::from_fn(move || { + Ok(std::iter::from_fn(move || { // loop until we find an attribute who's name does not start with underscore, // or we get to the end of the list of attributes let name = attributes_iterator.next()?; @@ -319,7 +319,7 @@ pub(crate) fn iterate_attributes<'a, 'py>( } } None - }) + })) } #[derive(Debug)] diff --git a/src/lookup_key.rs b/src/lookup_key.rs index bacdb5fd1..4cc131df8 100644 --- a/src/lookup_key.rs +++ b/src/lookup_key.rs @@ -504,7 +504,7 @@ impl PathItem { /// wrapper around `getattr` that returns `Ok(None)` for attribute errors, but returns other errors /// We don't check `try_from_attributes` because that check was performed on the top level object before we got here fn py_get_attrs<'py>(obj: &Bound<'py, PyAny>, attr_name: &Py) -> PyResult>> { - match obj.getattr(attr_name.extract::<&PyString>(obj.py())?) { + match obj.getattr(attr_name) { Ok(attr) => Ok(Some(attr)), Err(err) => { if err.get_type_bound(obj.py()).is_subclass_of::()? { diff --git a/src/serializers/errors.rs b/src/serializers/errors.rs index 71a0a024e..ffd43407f 100644 --- a/src/serializers/errors.rs +++ b/src/serializers/errors.rs @@ -105,6 +105,7 @@ impl PydanticSerializationUnexpectedValue { #[pymethods] impl PydanticSerializationUnexpectedValue { #[new] + #[pyo3(signature = (message=None))] fn py_new(message: Option) -> Self { Self { message } } diff --git a/src/serializers/extra.rs b/src/serializers/extra.rs index 88185ad6c..dbf6f7b31 100644 --- a/src/serializers/extra.rs +++ b/src/serializers/extra.rs @@ -4,7 +4,7 @@ use std::fmt; use pyo3::exceptions::{PyTypeError, PyValueError}; use pyo3::intern; use pyo3::prelude::*; -use pyo3::types::PyBool; +use pyo3::types::{PyBool, PyString}; use serde::ser::Error; @@ -423,7 +423,7 @@ impl CollectWarnings { let type_name = value .get_type() .qualname() - .unwrap_or_else(|_| "".to_owned()); + .unwrap_or_else(|_| PyString::new_bound(value.py(), "")); self.add_warning(format!( "Expected `{field_type}` but got `{type_name}` - serialized value may not be as expected" )); diff --git a/src/serializers/mod.rs b/src/serializers/mod.rs index 02ec71fd6..66b345530 100644 --- a/src/serializers/mod.rs +++ b/src/serializers/mod.rs @@ -86,6 +86,7 @@ impl SchemaSerializer { #[pymethods] impl SchemaSerializer { #[new] + #[pyo3(signature = (schema, config=None))] pub fn py_new(schema: Bound<'_, PyDict>, config: Option<&Bound<'_, PyDict>>) -> PyResult { let mut definitions_builder = DefinitionsBuilder::new(); let serializer = CombinedSerializer::build(schema.downcast()?, config, &mut definitions_builder)?; diff --git a/src/serializers/type_serializers/dataclass.rs b/src/serializers/type_serializers/dataclass.rs index 193e75b66..ebcca0dec 100644 --- a/src/serializers/type_serializers/dataclass.rs +++ b/src/serializers/type_serializers/dataclass.rs @@ -82,18 +82,18 @@ impl BuildSerializer for DataclassSerializer { // models ignore the parent config and always use the config from this model let config = schema.get_as(intern!(py, "config"))?; - let class: &PyType = schema.get_as_req(intern!(py, "cls"))?; + let class: Bound<'_, PyType> = schema.get_as_req(intern!(py, "cls"))?; let sub_schema = schema.get_as_req(intern!(py, "schema"))?; let serializer = Box::new(CombinedSerializer::build(&sub_schema, config.as_ref(), definitions)?); let fields = schema - .get_as_req::<&PyList>(intern!(py, "fields"))? + .get_as_req::>(intern!(py, "fields"))? .iter() .map(|s| Ok(s.downcast::()?.into_py(py))) .collect::>>()?; Ok(Self { - class: class.into(), + class: class.clone().unbind(), serializer, fields, name: class.getattr(intern!(py, "__name__"))?.extract()?, diff --git a/src/serializers/type_serializers/function.rs b/src/serializers/type_serializers/function.rs index 01bc6606a..856be6fb3 100644 --- a/src/serializers/type_serializers/function.rs +++ b/src/serializers/type_serializers/function.rs @@ -476,6 +476,7 @@ impl SerializationCallable { #[pymethods] impl SerializationCallable { + #[pyo3(signature = (value, index_key=None))] fn __call__( &mut self, py: Python, diff --git a/src/validators/dataclass.rs b/src/validators/dataclass.rs index 72d738440..4ff82a467 100644 --- a/src/validators/dataclass.rs +++ b/src/validators/dataclass.rs @@ -460,7 +460,7 @@ impl BuildValidator for DataclassValidator { let config = schema.get_as(intern!(py, "config"))?; let config = config.as_ref(); - let class: &PyType = schema.get_as_req(intern!(py, "cls"))?; + let class = schema.get_as_req::>(intern!(py, "cls"))?; let name = match schema.get_as_req::(intern!(py, "cls_name")) { Ok(name) => name, Err(_) => class.getattr(intern!(py, "__name__"))?.extract()?, @@ -474,11 +474,7 @@ impl BuildValidator for DataclassValidator { None }; - let fields = schema - .get_as_req::<&PyList>(intern!(py, "fields"))? - .iter() - .map(|s| Ok(s.downcast::()?.into_py(py))) - .collect::>>()?; + let fields = schema.get_as_req(intern!(py, "fields"))?; Ok(Self { strict: is_strict(schema, config)?, @@ -634,7 +630,7 @@ impl DataclassValidator { dc.call_method0(post_init) } else { let args = post_init_kwargs.downcast::()?; - dc.call_method1(post_init, args.as_gil_ref()) + dc.call_method1(post_init, args) }; r.map_err(|e| convert_err(py, e, input))?; } diff --git a/src/validators/datetime.rs b/src/validators/datetime.rs index 4874e78a3..a6ccad328 100644 --- a/src/validators/datetime.rs +++ b/src/validators/datetime.rs @@ -31,9 +31,7 @@ pub(crate) fn extract_microseconds_precision( schema_or_config_same(schema, config, intern!(schema.py(), "microseconds_precision"))? .map_or( Ok(speedate::MicrosecondsPrecisionOverflowBehavior::Truncate), - |v: &PyString| { - speedate::MicrosecondsPrecisionOverflowBehavior::try_from(v.extract::().unwrap().as_str()) - }, + |v: Bound<'_, PyString>| speedate::MicrosecondsPrecisionOverflowBehavior::try_from(v.to_str().unwrap()), ) .map_err(|_| { py_schema_error_type!("Invalid `microseconds_precision`, must be one of \"truncate\" or \"error\"") diff --git a/src/validators/decimal.rs b/src/validators/decimal.rs index 38409c9d4..d1c15c299 100644 --- a/src/validators/decimal.rs +++ b/src/validators/decimal.rs @@ -22,9 +22,8 @@ pub fn get_decimal_type(py: Python) -> &Bound<'_, PyType> { py.import_bound("decimal") .and_then(|decimal_module| decimal_module.getattr("Decimal")) .unwrap() - .extract::<&PyType>() + .extract() .unwrap() - .into() }) .bind(py) } diff --git a/src/validators/enum_.rs b/src/validators/enum_.rs index 087d0ca5f..0449a95da 100644 --- a/src/validators/enum_.rs +++ b/src/validators/enum_.rs @@ -137,7 +137,10 @@ impl Validator for EnumValidator { } else if !enum_value.is(&py.None()) { let type_error = PyTypeError::new_err(format!( "error in {}._missing_: returned {} instead of None or a valid member", - class.name().unwrap_or_else(|_| "".into()), + class + .name() + .and_then(|name| name.extract::()) + .unwrap_or_else(|_| "".into()), safe_repr(&enum_value) )); return Err(type_error.into()); diff --git a/src/validators/function.rs b/src/validators/function.rs index 855337a01..286107c92 100644 --- a/src/validators/function.rs +++ b/src/validators/function.rs @@ -36,9 +36,7 @@ fn destructure_function_schema(schema: &Bound<'_, PyDict>) -> PyResult false, _ => unreachable!(), }; - let field_name = func_dict - .get_as::<&PyString>(intern!(schema.py(), "field_name"))? - .map(Into::into); + let field_name = func_dict.get_as(intern!(schema.py(), "field_name"))?; Ok(FunctionInfo { function, field_name, @@ -394,6 +392,7 @@ struct ValidatorCallable { #[pymethods] impl ValidatorCallable { + #[pyo3(signature = (input_value, outer_location=None))] fn __call__( &mut self, py: Python, @@ -427,6 +426,7 @@ struct AssignmentValidatorCallable { #[pymethods] impl AssignmentValidatorCallable { + #[pyo3(signature = (input_value, outer_location=None))] fn __call__( &mut self, py: Python, diff --git a/src/validators/is_instance.rs b/src/validators/is_instance.rs index d904e82fb..d9190f33c 100644 --- a/src/validators/is_instance.rs +++ b/src/validators/is_instance.rs @@ -81,7 +81,7 @@ impl Validator for IsInstanceValidator { pub fn class_repr(schema: &Bound<'_, PyDict>, class: &Bound<'_, PyAny>) -> PyResult { match schema.get_as(intern!(schema.py(), "cls_repr"))? { Some(s) => Ok(s), - None => match class.extract::<&PyType>() { + None => match class.downcast::() { Ok(t) => Ok(t.qualname()?.to_string()), Err(_) => Ok(class.repr()?.extract()?), }, diff --git a/src/validators/is_subclass.rs b/src/validators/is_subclass.rs index 50deb8ae3..fdfea5b75 100644 --- a/src/validators/is_subclass.rs +++ b/src/validators/is_subclass.rs @@ -25,7 +25,7 @@ impl BuildValidator for IsSubclassValidator { _definitions: &mut DefinitionsBuilder, ) -> PyResult { let py = schema.py(); - let class: &PyType = schema.get_as_req(intern!(py, "cls"))?; + let class = schema.get_as_req::>(intern!(py, "cls"))?; let class_repr = match schema.get_as(intern!(py, "cls_repr"))? { Some(s) => s, diff --git a/src/validators/mod.rs b/src/validators/mod.rs index ede6489ab..02abda1fd 100644 --- a/src/validators/mod.rs +++ b/src/validators/mod.rs @@ -117,6 +117,7 @@ pub struct SchemaValidator { #[pymethods] impl SchemaValidator { #[new] + #[pyo3(signature = (schema, config=None))] pub fn py_new(py: Python, schema: &Bound<'_, PyAny>, config: Option<&Bound<'_, PyDict>>) -> PyResult { let mut definitions_builder = DefinitionsBuilder::new(); diff --git a/src/validators/url.rs b/src/validators/url.rs index 5ec3a139f..634d1ce43 100644 --- a/src/validators/url.rs +++ b/src/validators/url.rs @@ -578,7 +578,7 @@ trait CopyFromPyUrl { } fn get_allowed_schemas(schema: &Bound<'_, PyDict>, name: &'static str) -> PyResult<(AllowedSchemas, String)> { - match schema.get_as::<&PyList>(intern!(schema.py(), "allowed_schemes"))? { + match schema.get_as::>(intern!(schema.py(), "allowed_schemes"))? { Some(list) => { if list.is_empty() { return py_schema_err!("`allowed_schemes` should have length > 0"); diff --git a/src/validators/uuid.rs b/src/validators/uuid.rs index 1fad8f8ed..44aa22003 100644 --- a/src/validators/uuid.rs +++ b/src/validators/uuid.rs @@ -115,7 +115,10 @@ impl Validator for UuidValidator { } else if state.strict_or(self.strict) && state.extra().input_type == InputType::Python { Err(ValError::new( ErrorType::IsInstanceOf { - class: class.qualname().unwrap_or_else(|_| "UUID".to_owned()), + class: class + .qualname() + .and_then(|name| name.extract()) + .unwrap_or_else(|_| "UUID".to_owned()), context: None, }, input, From bfa816c448a0853b11b0682bc362682344310dcb Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Mon, 24 Jun 2024 15:36:30 +0100 Subject: [PATCH 2/8] build on Python 3.13 --- .github/workflows/ci.yml | 17 +++-- Cargo.lock | 136 +++++++++++++++++++-------------------- 2 files changed, 77 insertions(+), 76 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8bb82805..6a12b0686 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,7 @@ jobs: - '3.10' - '3.11' - '3.12' + - '3.13' - 'pypy3.9' - 'pypy3.10' @@ -88,6 +89,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true - run: pip install -r tests/requirements.txt @@ -411,15 +413,15 @@ jobs: - os: linux manylinux: auto target: armv7 - interpreter: 3.8 3.9 3.10 3.11 3.12 + interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 - os: linux manylinux: auto target: ppc64le - interpreter: 3.8 3.9 3.10 3.11 3.12 + interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 - os: linux manylinux: auto target: s390x - interpreter: 3.8 3.9 3.10 3.11 3.12 + interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 - os: linux manylinux: auto target: x86_64 @@ -452,11 +454,11 @@ jobs: - os: windows target: i686 python-architecture: x86 - interpreter: 3.8 3.9 3.10 3.11 3.12 + interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 # FIXME aarch64 builds broken, see https://github.com/PyO3/maturin/issues/2110 # - os: windows # target: aarch64 - # interpreter: 3.11 3.12 + # interpreter: 3.11 3.12 3.13 exclude: # See above; disabled for now. @@ -483,7 +485,7 @@ jobs: with: target: ${{ matrix.target }} manylinux: ${{ matrix.manylinux }} - args: --release --out dist --interpreter ${{ matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 pypy3.9 pypy3.10' }} + args: --release --out dist --interpreter ${{ matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' }} rust-toolchain: stable docker-options: -e CI @@ -504,7 +506,7 @@ jobs: fail-fast: false matrix: os: [linux, windows, macos] - interpreter: ['3.8', '3.9', '3.10', '3.11', '3.12'] + interpreter: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] include: # standard runners with override for macos arm - os: linux @@ -529,6 +531,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.interpreter }} + allow-prereleases: true - name: install rust stable id: rust-toolchain diff --git a/Cargo.lock b/Cargo.lock index 5998a79e3..cd4b075fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b79b82693f705137f8fb9b37871d99e4f9a7df12b917eed79c3d3954830a60b" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom", @@ -17,18 +17,18 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "base64" @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.79" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "c891175c3fb232128f48de6590095e59198bbeb8620c310be349bfc3afd12c7b" [[package]] name = "cfg-if" @@ -95,9 +95,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -106,9 +106,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heck" @@ -134,9 +134,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.2" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", @@ -144,15 +144,15 @@ dependencies = [ [[package]] name = "indoc" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "itoa" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jiter" @@ -207,54 +207,52 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "memchr" -version = "2.6.3" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", ] [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "percent-encoding" @@ -296,7 +294,7 @@ dependencies = [ "smallvec", "speedate", "strum", - "strum_macros 0.26.1", + "strum_macros 0.26.4", "url", "uuid", "version_check", @@ -305,7 +303,7 @@ dependencies = [ [[package]] name = "pyo3" version = "0.22.0" -source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#f846a6eae4c60c632508e9b645572f340d231900" +source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#ec6d4f8f1b477cbd5b968189f993d38c7330761a" dependencies = [ "cfg-if", "indoc", @@ -323,7 +321,7 @@ dependencies = [ [[package]] name = "pyo3-build-config" version = "0.22.0" -source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#f846a6eae4c60c632508e9b645572f340d231900" +source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#ec6d4f8f1b477cbd5b968189f993d38c7330761a" dependencies = [ "once_cell", "python3-dll-a", @@ -333,7 +331,7 @@ dependencies = [ [[package]] name = "pyo3-ffi" version = "0.22.0" -source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#f846a6eae4c60c632508e9b645572f340d231900" +source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#ec6d4f8f1b477cbd5b968189f993d38c7330761a" dependencies = [ "libc", "pyo3-build-config", @@ -342,7 +340,7 @@ dependencies = [ [[package]] name = "pyo3-macros" version = "0.22.0" -source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#f846a6eae4c60c632508e9b645572f340d231900" +source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#ec6d4f8f1b477cbd5b968189f993d38c7330761a" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -353,7 +351,7 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" version = "0.22.0" -source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#f846a6eae4c60c632508e9b645572f340d231900" +source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#ec6d4f8f1b477cbd5b968189f993d38c7330761a" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -373,9 +371,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -388,9 +386,9 @@ checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -400,9 +398,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -411,21 +409,21 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rustversion" -version = "1.0.13" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.14" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" @@ -449,9 +447,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "indexmap", "itoa", @@ -505,11 +503,11 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.26.1" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", @@ -556,21 +554,21 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] @@ -583,9 +581,9 @@ checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -594,9 +592,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "3ea73390fe27785838dcbf75b91b1d84799e28f1ce71e6f372a5dc2200c80de5" [[package]] name = "version_check" @@ -621,18 +619,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", From b10515e2759893fb1dd8d1232d11378923c35aa0 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Mon, 24 Jun 2024 15:54:47 +0100 Subject: [PATCH 3/8] don't PGO optimize windows & macOS 3.13 for now --- .github/workflows/ci.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a12b0686..5eb26d73c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -438,19 +438,25 @@ jobs: # macos; # all versions x86_64 # arm pypy and older pythons which can't be run on the arm hardware for PGO + # + # FIXME https://github.com/PyO3/maturin-action/issues/275 + # cffi prevents `maturin-action` working on Windows 3.13 for now for the optimized build - os: macos target: x86_64 - os: macos target: aarch64 - interpreter: 3.8 3.9 pypy3.9 pypy3.10 + interpreter: 3.8 3.9 pypy3.9 pypy3.10 3.13 # windows; # x86_64 pypy builds are not PGO optimized # i686 not supported by pypy # aarch64 only 3.11 and up, also not PGO optimized + # + # FIXME https://github.com/PyO3/maturin-action/issues/275 + # cffi prevents `maturin-action` working on Windows 3.13 for now for the optimized build - os: windows target: x86_64 - interpreter: pypy3.9 pypy3.10 + interpreter: pypy3.9 pypy3.10 3.13 - os: windows target: i686 python-architecture: x86 @@ -522,6 +528,12 @@ jobs: interpreter: '3.8' - os: macos interpreter: '3.9' + # https://github.com/PyO3/maturin-action/issues/275 + # cffi prevents `maturin-action` working on Windows & macOS 3.13 for now + - os: windows + interpreter: '3.13' + - os: macos + interpreter: '3.13' runs-on: ${{ matrix.runs-on }} steps: From 0a4ee34decbd7b7ce6b001666912d00eca5957db Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Mon, 24 Jun 2024 15:58:18 +0100 Subject: [PATCH 4/8] adjust test output for 3.13 --- tests/validators/test_string.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/validators/test_string.py b/tests/validators/test_string.py index 75edcc1b0..df6bd7ad7 100644 --- a/tests/validators/test_string.py +++ b/tests/validators/test_string.py @@ -1,4 +1,5 @@ import re +import sys from decimal import Decimal from numbers import Number from typing import Any, Dict, Union @@ -187,8 +188,9 @@ def test_invalid_regex(engine): 'error: unclosed group' ) elif engine == 'python-re': + prefix = 'PatternError' if sys.version_info >= (3, 13) else 'error' assert exc_info.value.args[0] == ( - 'Error building "str" validator:\n error: missing ), unterminated subpattern at position 0' + f'Error building "str" validator:\n {prefix}: missing ), unterminated subpattern at position 0' ) From fb58ce85e376806a005fc30e5f90e7f10b754599 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Mon, 24 Jun 2024 16:33:41 +0100 Subject: [PATCH 5/8] just disable Windows 3.13 builds entirely for now --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5eb26d73c..1a76130f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -440,12 +440,12 @@ jobs: # arm pypy and older pythons which can't be run on the arm hardware for PGO # # FIXME https://github.com/PyO3/maturin-action/issues/275 - # cffi prevents `maturin-action` working on Windows 3.13 for now for the optimized build + # cffi prevents `maturin-action` working on macOS 3.13 for now for the optimized build - os: macos target: x86_64 - os: macos target: aarch64 - interpreter: 3.8 3.9 pypy3.9 pypy3.10 3.13 + interpreter: 3.8 3.9 pypy3.9 pypy3.10 # 3.13 # windows; # x86_64 pypy builds are not PGO optimized @@ -454,13 +454,15 @@ jobs: # # FIXME https://github.com/PyO3/maturin-action/issues/275 # cffi prevents `maturin-action` working on Windows 3.13 for now for the optimized build + # AND FIXME https://github.com/PyO3/python3-dll-a/issues/69 + # prevents older Python versions from building 3.13 - os: windows target: x86_64 - interpreter: pypy3.9 pypy3.10 3.13 + interpreter: pypy3.9 pypy3.10 # 3.13 - os: windows target: i686 python-architecture: x86 - interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 + interpreter: 3.8 3.9 3.10 3.11 3.12 # 3.13 # FIXME aarch64 builds broken, see https://github.com/PyO3/maturin/issues/2110 # - os: windows # target: aarch64 From 2c1012b76d19b98324121648c5416ea955c74bec Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Mon, 24 Jun 2024 16:36:27 +0100 Subject: [PATCH 6/8] add 3.13 classifier --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index e1edd165f..97ee3319f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ classifiers = [ 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', 'Programming Language :: Rust', 'Framework :: Pydantic', 'Intended Audience :: Developers', From ae0bdd0c6cb1d151b6dc868d1fc2f5319c352466 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Mon, 24 Jun 2024 23:14:24 +0100 Subject: [PATCH 7/8] use released versions of crates --- Cargo.lock | 20 +++++++++++++------- Cargo.toml | 7 +------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cd4b075fa..17af933ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -156,8 +156,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jiter" -version = "0.4.2" -source = "git+https://github.com/pydantic/jiter?branch=dh/pyo3-0.22#e1b18fec7d4e0d7747f9767a50874bcbe00468e0" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e23549143ef50eddffd46ba8cd0229b0a4500aef7518cf2eb0f41c9a09d22b" dependencies = [ "ahash", "bitvec", @@ -303,7 +304,8 @@ dependencies = [ [[package]] name = "pyo3" version = "0.22.0" -source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#ec6d4f8f1b477cbd5b968189f993d38c7330761a" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1962a33ed2a201c637fc14a4e0fd4e06e6edfdeee6a5fede0dab55507ad74cf7" dependencies = [ "cfg-if", "indoc", @@ -321,7 +323,8 @@ dependencies = [ [[package]] name = "pyo3-build-config" version = "0.22.0" -source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#ec6d4f8f1b477cbd5b968189f993d38c7330761a" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab7164b2202753bd33afc7f90a10355a719aa973d1f94502c50d06f3488bc420" dependencies = [ "once_cell", "python3-dll-a", @@ -331,7 +334,8 @@ dependencies = [ [[package]] name = "pyo3-ffi" version = "0.22.0" -source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#ec6d4f8f1b477cbd5b968189f993d38c7330761a" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6424906ca49013c0829c5c1ed405e20e2da2dc78b82d198564880a704e6a7b7" dependencies = [ "libc", "pyo3-build-config", @@ -340,7 +344,8 @@ dependencies = [ [[package]] name = "pyo3-macros" version = "0.22.0" -source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#ec6d4f8f1b477cbd5b968189f993d38c7330761a" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b2f19e153122d64afd8ce7aaa72f06a00f52e34e1d1e74b6d71baea396460a" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -351,7 +356,8 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" version = "0.22.0" -source = "git+https://github.com/pyo3/pyo3?branch=release-0.22#ec6d4f8f1b477cbd5b968189f993d38c7330761a" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd698c04cac17cf0fe63d47790ab311b8b25542f5cb976b65c374035c50f1eef" dependencies = [ "heck 0.5.0", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index c03944c60..d2091479d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ base64 = "0.21.7" num-bigint = "0.4.4" python3-dll-a = "0.2.7" uuid = "1.8.0" -jiter = { version = "0.4.1", features = ["python"] } +jiter = { version = "0.5", features = ["python"] } [lib] name = "_pydantic_core" @@ -110,8 +110,3 @@ too_many_lines = "allow" unnecessary_wraps = "allow" unused_self = "allow" used_underscore_binding = "allow" - -[patch.crates-io] -pyo3 = { git = "https://github.com/pyo3/pyo3", branch = "release-0.22" } -pyo3-build-config = { git = "https://github.com/pyo3/pyo3", branch = "release-0.22" } -jiter = { git = "https://github.com/pydantic/jiter", branch = "dh/pyo3-0.22" } From 77387e4e49b5045c9cfbe1fb5bdd0e52737e8a8a Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Mon, 24 Jun 2024 23:26:18 +0100 Subject: [PATCH 8/8] restore Windows 3.13 builds --- .github/workflows/ci.yml | 6 ++---- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a76130f6..6b7be62c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -454,15 +454,13 @@ jobs: # # FIXME https://github.com/PyO3/maturin-action/issues/275 # cffi prevents `maturin-action` working on Windows 3.13 for now for the optimized build - # AND FIXME https://github.com/PyO3/python3-dll-a/issues/69 - # prevents older Python versions from building 3.13 - os: windows target: x86_64 - interpreter: pypy3.9 pypy3.10 # 3.13 + interpreter: pypy3.9 pypy3.10 3.13 - os: windows target: i686 python-architecture: x86 - interpreter: 3.8 3.9 3.10 3.11 3.12 # 3.13 + interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 # FIXME aarch64 builds broken, see https://github.com/PyO3/maturin/issues/2110 # - os: windows # target: aarch64 diff --git a/Cargo.lock b/Cargo.lock index 17af933ac..cdcde2cd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -368,9 +368,9 @@ dependencies = [ [[package]] name = "python3-dll-a" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f07cd4412be8fa09a721d40007c483981bbe072cd6a21f2e83e04ec8f8343f" +checksum = "bd0b78171a90d808b319acfad166c4790d9e9759bbc14ac8273fe133673dd41b" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index d2091479d..a268e0a69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ url = "2.5.0" idna = "0.5.0" base64 = "0.21.7" num-bigint = "0.4.4" -python3-dll-a = "0.2.7" +python3-dll-a = "0.2.10" uuid = "1.8.0" jiter = { version = "0.5", features = ["python"] }