Skip to content

Commit

Permalink
Fix lint errors with toolchain 1.83 (#1561)
Browse files Browse the repository at this point in the history
  • Loading branch information
changhc authored and davidhewitt committed Dec 18, 2024
1 parent 253cfe0 commit 6eee20d
Show file tree
Hide file tree
Showing 23 changed files with 178 additions and 89 deletions.
4 changes: 2 additions & 2 deletions src/errors/validation_exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ struct ValidationErrorSerializer<'py> {
input_type: &'py InputType,
}

impl<'py> Serialize for ValidationErrorSerializer<'py> {
impl Serialize for ValidationErrorSerializer<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down Expand Up @@ -614,7 +614,7 @@ struct PyLineErrorSerializer<'py> {
input_type: &'py InputType,
}

impl<'py> Serialize for PyLineErrorSerializer<'py> {
impl Serialize for PyLineErrorSerializer<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
12 changes: 6 additions & 6 deletions src/input/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum EitherDate<'a> {
Py(Bound<'a, PyDate>),
}

impl<'a> From<Date> for EitherDate<'a> {
impl From<Date> for EitherDate<'_> {
fn from(date: Date) -> Self {
Self::Raw(date)
}
Expand All @@ -45,7 +45,7 @@ pub fn pydate_as_date(py_date: &Bound<'_, PyAny>) -> PyResult<Date> {
})
}

impl<'a> EitherDate<'a> {
impl EitherDate<'_> {
pub fn as_raw(&self) -> PyResult<Date> {
match self {
Self::Raw(date) => Ok(date.clone()),
Expand All @@ -68,7 +68,7 @@ pub enum EitherTime<'a> {
Py(Bound<'a, PyTime>),
}

impl<'a> From<Time> for EitherTime<'a> {
impl From<Time> for EitherTime<'_> {
fn from(time: Time) -> Self {
Self::Raw(time)
}
Expand All @@ -87,7 +87,7 @@ pub enum EitherTimedelta<'a> {
PySubclass(Bound<'a, PyDelta>),
}

impl<'a> From<Duration> for EitherTimedelta<'a> {
impl From<Duration> for EitherTimedelta<'_> {
fn from(timedelta: Duration) -> Self {
Self::Raw(timedelta)
}
Expand Down Expand Up @@ -200,7 +200,7 @@ pub fn pytime_as_time(py_time: &Bound<'_, PyAny>, py_dt: Option<&Bound<'_, PyAny
})
}

impl<'a> EitherTime<'a> {
impl EitherTime<'_> {
pub fn as_raw(&self) -> PyResult<Time> {
match self {
Self::Raw(time) => Ok(time.clone()),
Expand Down Expand Up @@ -240,7 +240,7 @@ pub enum EitherDateTime<'a> {
Py(Bound<'a, PyDateTime>),
}

impl<'a> From<DateTime> for EitherDateTime<'a> {
impl From<DateTime> for EitherDateTime<'_> {
fn from(dt: DateTime) -> Self {
Self::Raw(dt)
}
Expand Down
16 changes: 12 additions & 4 deletions src/input/input_abstract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ pub trait ValidatedSet<'py> {

/// This type is used for inputs which don't support certain types.
/// It implements all the associated traits, but never actually gets called.
pub enum Never {}

impl<'py> ValidatedDict<'py> for Never {
Expand Down Expand Up @@ -325,7 +324,10 @@ impl Arguments<'_> for Never {
}

impl<'py> PositionalArgs<'py> for Never {
type Item<'a> = Bound<'py, PyAny> where Self: 'a;
type Item<'a>
= Bound<'py, PyAny>
where
Self: 'a;
fn len(&self) -> usize {
unreachable!()
}
Expand All @@ -338,8 +340,14 @@ impl<'py> PositionalArgs<'py> for Never {
}

impl<'py> KeywordArgs<'py> for Never {
type Key<'a> = Bound<'py, PyAny> where Self: 'a;
type Item<'a> = Bound<'py, PyAny> where Self: 'a;
type Key<'a>
= Bound<'py, PyAny>
where
Self: 'a;
type Item<'a>
= Bound<'py, PyAny>
where
Self: 'a;
fn len(&self) -> usize {
unreachable!()
}
Expand Down
54 changes: 41 additions & 13 deletions src/input/input_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ impl<'py, 'data> Input<'py> for JsonValue<'data> {
}
}

type Arguments<'a> = JsonArgs<'a, 'data>
type Arguments<'a>
= JsonArgs<'a, 'data>
where
Self: 'a,;
Self: 'a;

fn validate_args(&self) -> ValResult<JsonArgs<'_, 'data>> {
match self {
Expand Down Expand Up @@ -179,7 +180,10 @@ impl<'py, 'data> Input<'py> for JsonValue<'data> {
}
}

type Dict<'a> = &'a JsonObject<'data> where Self: 'a;
type Dict<'a>
= &'a JsonObject<'data>
where
Self: 'a;

fn validate_dict(&self, _strict: bool) -> ValResult<Self::Dict<'_>> {
match self {
Expand All @@ -192,7 +196,10 @@ impl<'py, 'data> Input<'py> for JsonValue<'data> {
self.validate_dict(false)
}

type List<'a> = &'a JsonArray<'data> where Self: 'a;
type List<'a>
= &'a JsonArray<'data>
where
Self: 'a;

fn validate_list(&self, _strict: bool) -> ValMatch<&JsonArray<'data>> {
match self {
Expand All @@ -201,7 +208,10 @@ impl<'py, 'data> Input<'py> for JsonValue<'data> {
}
}

type Tuple<'a> = &'a JsonArray<'data> where Self: 'a;
type Tuple<'a>
= &'a JsonArray<'data>
where
Self: 'a;

fn validate_tuple(&self, _strict: bool) -> ValMatch<&JsonArray<'data>> {
// just as in set's case, List has to be allowed
Expand All @@ -211,7 +221,10 @@ impl<'py, 'data> Input<'py> for JsonValue<'data> {
}
}

type Set<'a> = &'a JsonArray<'data> where Self: 'a;
type Set<'a>
= &'a JsonArray<'data>
where
Self: 'a;

fn validate_set(&self, _strict: bool) -> ValMatch<&JsonArray<'data>> {
// we allow a list here since otherwise it would be impossible to create a set from JSON
Expand Down Expand Up @@ -501,10 +514,16 @@ fn string_to_vec(s: &str) -> JsonArray<'static> {
JsonArray::new(s.chars().map(|c| JsonValue::Str(c.to_string().into())).collect())
}

impl<'py, 'data> ValidatedDict<'py> for &'_ JsonObject<'data> {
type Key<'a> = &'a str where Self: 'a;
impl<'data> ValidatedDict<'_> for &'_ JsonObject<'data> {
type Key<'a>
= &'a str
where
Self: 'a;

type Item<'a> = &'a JsonValue<'data> where Self: 'a;
type Item<'a>
= &'a JsonValue<'data>
where
Self: 'a;

fn get_item<'k>(&self, key: &'k LookupKey) -> ValResult<Option<(&'k LookupPath, Self::Item<'_>)>> {
key.json_get(self)
Expand Down Expand Up @@ -567,7 +586,7 @@ impl<'a, 'data> JsonArgs<'a, 'data> {
}
}

impl<'a, 'data> Arguments<'_> for JsonArgs<'a, 'data> {
impl<'data> Arguments<'_> for JsonArgs<'_, 'data> {
type Args = [JsonValue<'data>];
type Kwargs = JsonObject<'data>;

Expand All @@ -581,7 +600,10 @@ impl<'a, 'data> Arguments<'_> for JsonArgs<'a, 'data> {
}

impl<'data> PositionalArgs<'_> for [JsonValue<'data>] {
type Item<'a> = &'a JsonValue<'data> where Self: 'a;
type Item<'a>
= &'a JsonValue<'data>
where
Self: 'a;

fn len(&self) -> usize {
<[JsonValue]>::len(self)
Expand All @@ -595,8 +617,14 @@ impl<'data> PositionalArgs<'_> for [JsonValue<'data>] {
}

impl<'data> KeywordArgs<'_> for JsonObject<'data> {
type Key<'a> = &'a str where Self: 'a;
type Item<'a> = &'a JsonValue<'data> where Self: 'a;
type Key<'a>
= &'a str
where
Self: 'a;
type Item<'a>
= &'a JsonValue<'data>
where
Self: 'a;

fn len(&self) -> usize {
LazyIndexMap::len(self)
Expand Down
42 changes: 32 additions & 10 deletions src/input/input_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ impl<'py> Input<'py> for Bound<'py, PyAny> {
.map(|dict| dict.to_owned().unbind().into_bound(py))
}

type Arguments<'a> = PyArgs<'py> where Self: 'a;
type Arguments<'a>
= PyArgs<'py>
where
Self: 'a;

fn validate_args(&self) -> ValResult<PyArgs<'py>> {
if let Ok(dict) = self.downcast::<PyDict>() {
Expand Down Expand Up @@ -350,7 +353,10 @@ impl<'py> Input<'py> for Bound<'py, PyAny> {
Err(ValError::new(error_type, self))
}

type Dict<'a> = GenericPyMapping<'a, 'py> where Self: 'a;
type Dict<'a>
= GenericPyMapping<'a, 'py>
where
Self: 'a;

fn strict_dict<'a>(&'a self) -> ValResult<GenericPyMapping<'a, 'py>> {
if let Ok(dict) = self.downcast::<PyDict>() {
Expand Down Expand Up @@ -404,7 +410,10 @@ impl<'py> Input<'py> for Bound<'py, PyAny> {
}
}

type List<'a> = PySequenceIterable<'a, 'py> where Self: 'a;
type List<'a>
= PySequenceIterable<'a, 'py>
where
Self: 'a;

fn validate_list<'a>(&'a self, strict: bool) -> ValMatch<PySequenceIterable<'a, 'py>> {
if let Ok(list) = self.downcast::<PyList>() {
Expand All @@ -418,7 +427,10 @@ impl<'py> Input<'py> for Bound<'py, PyAny> {
Err(ValError::new(ErrorTypeDefaults::ListType, self))
}

type Tuple<'a> = PySequenceIterable<'a, 'py> where Self: 'a;
type Tuple<'a>
= PySequenceIterable<'a, 'py>
where
Self: 'a;

fn validate_tuple<'a>(&'a self, strict: bool) -> ValMatch<PySequenceIterable<'a, 'py>> {
if let Ok(tup) = self.downcast::<PyTuple>() {
Expand All @@ -432,7 +444,10 @@ impl<'py> Input<'py> for Bound<'py, PyAny> {
Err(ValError::new(ErrorTypeDefaults::TupleType, self))
}

type Set<'a> = PySequenceIterable<'a, 'py> where Self: 'a;
type Set<'a>
= PySequenceIterable<'a, 'py>
where
Self: 'a;

fn validate_set<'a>(&'a self, strict: bool) -> ValMatch<PySequenceIterable<'a, 'py>> {
if let Ok(set) = self.downcast::<PySet>() {
Expand Down Expand Up @@ -742,7 +757,10 @@ impl<'py> Arguments<'py> for PyArgs<'py> {
}

impl<'py> PositionalArgs<'py> for PyPosArgs<'py> {
type Item<'a> = Borrowed<'a, 'py, PyAny> where Self: 'a;
type Item<'a>
= Borrowed<'a, 'py, PyAny>
where
Self: 'a;

fn len(&self) -> usize {
self.0.len()
Expand All @@ -758,11 +776,13 @@ impl<'py> PositionalArgs<'py> for PyPosArgs<'py> {
}

impl<'py> KeywordArgs<'py> for PyKwargs<'py> {
type Key<'a> = Bound<'py, PyAny>
type Key<'a>
= Bound<'py, PyAny>
where
Self: 'a;

type Item<'a> = Bound<'py, PyAny>
type Item<'a>
= Bound<'py, PyAny>
where
Self: 'a;

Expand Down Expand Up @@ -790,11 +810,13 @@ pub enum GenericPyMapping<'a, 'py> {
}

impl<'py> ValidatedDict<'py> for GenericPyMapping<'_, 'py> {
type Key<'a> = Bound<'py, PyAny>
type Key<'a>
= Bound<'py, PyAny>
where
Self: 'a;

type Item<'a> = Bound<'py, PyAny>
type Item<'a>
= Bound<'py, PyAny>
where
Self: 'a;

Expand Down
Loading

0 comments on commit 6eee20d

Please sign in to comment.