Skip to content

Commit 1ea1fef

Browse files
authored
fix: make everything work on nightly (#1776)
1 parent 68a1e7b commit 1ea1fef

File tree

11 files changed

+14
-14
lines changed

11 files changed

+14
-14
lines changed

src/common/missing_sentinel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use pyo3::sync::GILOnceCell;
44

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

7-
pub fn get_missing_sentinel_object(py: Python) -> &Bound<'_, PyAny> {
7+
pub fn get_missing_sentinel_object(py: Python<'_>) -> &Bound<'_, PyAny> {
88
MISSING_SENTINEL_OBJECT
99
.get_or_init(py, || {
1010
py.import(intern!(py, "pydantic_core"))

src/errors/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::tools::{extract_i64, py_err, py_error_type};
1818
use super::PydanticCustomError;
1919

2020
#[pyfunction]
21-
pub fn list_all_errors(py: Python) -> PyResult<Bound<'_, PyList>> {
21+
pub fn list_all_errors(py: Python<'_>) -> PyResult<Bound<'_, PyList>> {
2222
let mut errors: Vec<Bound<'_, PyDict>> = Vec::with_capacity(100);
2323
for error_type in ErrorType::iter() {
2424
if !matches!(error_type, ErrorType::CustomError { .. }) {

src/errors/validation_exception.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ fn get_formated_url(py: Python) -> &'static str {
238238
URL_PREFIX.get_or_init(py, || format!("https://errors.pydantic.dev/{pydantic_version}/v/"))
239239
}
240240

241-
fn get_url_prefix(py: Python, include_url: bool) -> Option<&str> {
241+
fn get_url_prefix(py: Python<'_>, include_url: bool) -> Option<&str> {
242242
if include_url {
243243
Some(get_formated_url(py))
244244
} else {

src/input/input_python.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use super::{
4949

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

52-
pub fn get_fraction_type(py: Python) -> &Bound<'_, PyType> {
52+
pub fn get_fraction_type(py: Python<'_>) -> &Bound<'_, PyType> {
5353
FRACTION_TYPE
5454
.get_or_init(py, || {
5555
py.import("fractions")

src/input/return_enums.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ pub enum EitherString<'a> {
474474
}
475475

476476
impl<'a> EitherString<'a> {
477-
pub fn as_cow(&self) -> ValResult<Cow<str>> {
477+
pub fn as_cow(&self) -> ValResult<Cow<'_, str>> {
478478
match self {
479479
Self::Cow(data) => Ok(data.clone()),
480480
Self::Py(py_str) => Ok(Cow::Borrowed(py_string_str(py_str)?)),

src/input/shared.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::errors::{ErrorTypeDefaults, ValError, ValResult};
1111
use super::{EitherFloat, EitherInt, Input};
1212
static ENUM_META_OBJECT: GILOnceCell<Py<PyAny>> = GILOnceCell::new();
1313

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

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

114114
// strip leading and trailing whitespace

src/validators/complex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::{BuildValidator, CombinedValidator, DefinitionsBuilder, ValidationSta
1111

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

14-
pub fn get_complex_type(py: Python) -> &Bound<'_, PyType> {
14+
pub fn get_complex_type(py: Python<'_>) -> &Bound<'_, PyType> {
1515
COMPLEX_TYPE
1616
.get_or_init(py, || py.get_type::<PyComplex>().into())
1717
.bind(py)

src/validators/dataclass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ impl Validator for DataclassValidator {
542542
// if the model has a generic origin, we allow input data to be instances of the generic origin rather than the class,
543543
// as cases like isinstance(SomeModel[Int], SomeModel[Any]) fail the isinstance check, but are valid, we just have to enforce
544544
// that the data is revalidated, hence we set force_revalidate to true
545-
if generic_origin_class.is_some() {
546-
match input_as_python_instance(input, generic_origin_class.unwrap()) {
545+
if let Some(generic_origin) = generic_origin_class {
546+
match input_as_python_instance(input, generic_origin) {
547547
Some(x) => (Some(x), true),
548548
None => (None, false),
549549
}

src/validators/decimal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use super::{BuildValidator, CombinedValidator, DefinitionsBuilder, ValidationSta
1616

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

19-
pub fn get_decimal_type(py: Python) -> &Bound<'_, PyType> {
19+
pub fn get_decimal_type(py: Python<'_>) -> &Bound<'_, PyType> {
2020
DECIMAL_TYPE
2121
.get_or_init(py, || {
2222
py.import("decimal")

src/validators/model.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ impl Validator for ModelValidator {
140140
// if the model has a generic origin, we allow input data to be instances of the generic origin rather than the class,
141141
// as cases like isinstance(SomeModel[Int], SomeModel[Any]) fail the isinstance check, but are valid, we just have to enforce
142142
// that the data is revalidated, hence we set force_revalidate to true
143-
if generic_origin_class.is_some() {
144-
match input_as_python_instance(input, generic_origin_class.unwrap()) {
143+
if let Some(generic_origin) = generic_origin_class {
144+
match input_as_python_instance(input, generic_origin) {
145145
Some(x) => (Some(x), true),
146146
None => (None, false),
147147
}

0 commit comments

Comments
 (0)