Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 28 additions & 139 deletions Cargo.lock

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

13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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" }
1 change: 1 addition & 0 deletions src/argument_markers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/errors/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ static ERROR_TYPE_LOOKUP: GILOnceCell<AHashMap<String, ErrorType>> = 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),
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/errors/value_exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bound<'_, PyDict>>) -> Self {
Self {
error_type,
Expand All @@ -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]
Expand Down Expand Up @@ -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<Bound<'_, PyDict>>) -> PyResult<Self> {
let error_type = ErrorType::new(py, error_type, context)?;
Ok(Self { error_type })
Expand Down
Loading