Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/common/missing_sentinel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use pyo3::sync::GILOnceCell;

static MISSING_SENTINEL_OBJECT: GILOnceCell<Py<PyAny>> = GILOnceCell::new();

pub fn get_missing_sentinel_object(py: Python) -> &Bound<'_, PyAny> {
pub fn get_missing_sentinel_object(py: Python<'_>) -> &Bound<'_, PyAny> {
MISSING_SENTINEL_OBJECT
.get_or_init(py, || {
py.import(intern!(py, "pydantic_core"))
Expand Down
2 changes: 1 addition & 1 deletion src/errors/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::tools::{extract_i64, py_err, py_error_type};
use super::PydanticCustomError;

#[pyfunction]
pub fn list_all_errors(py: Python) -> PyResult<Bound<'_, PyList>> {
pub fn list_all_errors(py: Python<'_>) -> PyResult<Bound<'_, PyList>> {
let mut errors: Vec<Bound<'_, PyDict>> = Vec::with_capacity(100);
for error_type in ErrorType::iter() {
if !matches!(error_type, ErrorType::CustomError { .. }) {
Expand Down
2 changes: 1 addition & 1 deletion src/errors/validation_exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn get_formated_url(py: Python) -> &'static str {
URL_PREFIX.get_or_init(py, || format!("https://errors.pydantic.dev/{pydantic_version}/v/"))
}

fn get_url_prefix(py: Python, include_url: bool) -> Option<&str> {
fn get_url_prefix(py: Python<'_>, include_url: bool) -> Option<&str> {
if include_url {
Some(get_formated_url(py))
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/input/input_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use super::{

static FRACTION_TYPE: GILOnceCell<Py<PyType>> = GILOnceCell::new();

pub fn get_fraction_type(py: Python) -> &Bound<'_, PyType> {
pub fn get_fraction_type(py: Python<'_>) -> &Bound<'_, PyType> {
FRACTION_TYPE
.get_or_init(py, || {
py.import("fractions")
Expand Down
2 changes: 1 addition & 1 deletion src/input/return_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ pub enum EitherString<'a> {
}

impl<'a> EitherString<'a> {
pub fn as_cow(&self) -> ValResult<Cow<str>> {
pub fn as_cow(&self) -> ValResult<Cow<'_, str>> {
match self {
Self::Cow(data) => Ok(data.clone()),
Self::Py(py_str) => Ok(Cow::Borrowed(py_string_str(py_str)?)),
Expand Down
4 changes: 2 additions & 2 deletions src/input/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::errors::{ErrorTypeDefaults, ValError, ValResult};
use super::{EitherFloat, EitherInt, Input};
static ENUM_META_OBJECT: GILOnceCell<Py<PyAny>> = GILOnceCell::new();

pub fn get_enum_meta_object(py: Python) -> &Bound<'_, PyAny> {
pub fn get_enum_meta_object(py: Python<'_>) -> &Bound<'_, PyAny> {
ENUM_META_OBJECT
.get_or_init(py, || {
py.import(intern!(py, "enum"))
Expand Down Expand Up @@ -108,7 +108,7 @@ pub fn str_as_float<'py>(input: &(impl Input<'py> + ?Sized), str: &str) -> ValRe
}
}

fn clean_int_str(mut s: &str) -> Option<Cow<str>> {
fn clean_int_str(mut s: &str) -> Option<Cow<'_, str>> {
let len_before = s.len();

// strip leading and trailing whitespace
Expand Down
2 changes: 1 addition & 1 deletion src/validators/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::{BuildValidator, CombinedValidator, DefinitionsBuilder, ValidationSta

static COMPLEX_TYPE: GILOnceCell<Py<PyType>> = GILOnceCell::new();

pub fn get_complex_type(py: Python) -> &Bound<'_, PyType> {
pub fn get_complex_type(py: Python<'_>) -> &Bound<'_, PyType> {
COMPLEX_TYPE
.get_or_init(py, || py.get_type::<PyComplex>().into())
.bind(py)
Expand Down
4 changes: 2 additions & 2 deletions src/validators/dataclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ impl Validator for DataclassValidator {
// if the model has a generic origin, we allow input data to be instances of the generic origin rather than the class,
// as cases like isinstance(SomeModel[Int], SomeModel[Any]) fail the isinstance check, but are valid, we just have to enforce
// that the data is revalidated, hence we set force_revalidate to true
if generic_origin_class.is_some() {
match input_as_python_instance(input, generic_origin_class.unwrap()) {
if let Some(generic_origin) = generic_origin_class {
match input_as_python_instance(input, generic_origin) {
Some(x) => (Some(x), true),
None => (None, false),
}
Expand Down
2 changes: 1 addition & 1 deletion src/validators/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::{BuildValidator, CombinedValidator, DefinitionsBuilder, ValidationSta

static DECIMAL_TYPE: GILOnceCell<Py<PyType>> = GILOnceCell::new();

pub fn get_decimal_type(py: Python) -> &Bound<'_, PyType> {
pub fn get_decimal_type(py: Python<'_>) -> &Bound<'_, PyType> {
DECIMAL_TYPE
.get_or_init(py, || {
py.import("decimal")
Expand Down
4 changes: 2 additions & 2 deletions src/validators/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ impl Validator for ModelValidator {
// if the model has a generic origin, we allow input data to be instances of the generic origin rather than the class,
// as cases like isinstance(SomeModel[Int], SomeModel[Any]) fail the isinstance check, but are valid, we just have to enforce
// that the data is revalidated, hence we set force_revalidate to true
if generic_origin_class.is_some() {
match input_as_python_instance(input, generic_origin_class.unwrap()) {
if let Some(generic_origin) = generic_origin_class {
match input_as_python_instance(input, generic_origin) {
Some(x) => (Some(x), true),
None => (None, false),
}
Expand Down
2 changes: 1 addition & 1 deletion src/validators/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn import_type(py: Python, module: &str, attr: &str) -> PyResult<Py<PyType>> {
py.import(module)?.getattr(attr)?.extract()
}

fn get_uuid_type(py: Python) -> PyResult<&Bound<'_, PyType>> {
fn get_uuid_type(py: Python<'_>) -> PyResult<&Bound<'_, PyType>> {
Ok(UUID_TYPE
.get_or_init(py, || import_type(py, "uuid", "UUID").unwrap())
.bind(py))
Expand Down
Loading