Skip to content

Commit ea5c832

Browse files
authored
fix linting for newest clippy (#309)
1 parent 5731c23 commit ea5c832

File tree

19 files changed

+47
-47
lines changed

19 files changed

+47
-47
lines changed

benches/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn list_int_python_isinstance(bench: &mut Bencher) {
8989
let (validator, input) = list_int_input(py);
9090
let input = black_box(input.as_ref(py));
9191
let v = validator.isinstance_python(py, input, None, None).unwrap();
92-
assert_eq!(v, true);
92+
assert!(v);
9393

9494
bench.iter(|| {
9595
let v = validator.isinstance_python(py, input, None, None).unwrap();
@@ -177,7 +177,7 @@ fn list_error_python_isinstance(bench: &mut Bencher) {
177177
let r = validator
178178
.isinstance_python(py, black_box(input.as_ref(py)), None, None)
179179
.unwrap();
180-
assert_eq!(r, false);
180+
assert!(!r);
181181

182182
let input = black_box(input.as_ref(py));
183183
bench.iter(|| {
@@ -235,7 +235,7 @@ fn dict_json(bench: &mut Bencher) {
235235
let code = format!(
236236
"{{{}}}",
237237
(0..100_u8)
238-
.map(|i| format!(r#""{}": {}"#, as_str(i), i))
238+
.map(|i| format!(r#""{}": {i}"#, as_str(i)))
239239
.collect::<Vec<String>>()
240240
.join(", ")
241241
);
@@ -255,7 +255,7 @@ fn dict_python(bench: &mut Bencher) {
255255
let code = format!(
256256
"{{{}}}",
257257
(0..100_u8)
258-
.map(|i| format!(r#""{}{}": {}"#, as_char(i / 26), as_char(i), i))
258+
.map(|i| format!(r#""{}{}": {i}"#, as_char(i / 26), as_char(i)))
259259
.collect::<Vec<String>>()
260260
.join(", ")
261261
);
@@ -283,7 +283,7 @@ fn dict_value_error(bench: &mut Bencher) {
283283
let code = format!(
284284
"{{{}}}",
285285
(0..100_u8)
286-
.map(|i| format!(r#""{}": {}"#, as_str(i), i))
286+
.map(|i| format!(r#""{}": {i}"#, as_str(i)))
287287
.collect::<Vec<String>>()
288288
.join(", ")
289289
);
@@ -404,7 +404,7 @@ fn typed_dict_deep_error(bench: &mut Bencher) {
404404

405405
let code = "{'field_a': '1', 'field_b': {'field_c': '2', 'field_d': {'field_e': '4', 'field_f': 'xx'}}}";
406406

407-
let input = py.eval(&code, None, None).unwrap();
407+
let input = py.eval(code, None, None).unwrap();
408408
let input = black_box(input);
409409

410410
match validator.validate_python(py, input, None, None) {

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn generate_self_schema() {
1818
if !output.status.success() {
1919
let stdout = from_utf8(&output.stdout).unwrap();
2020
let stderr = from_utf8(&output.stderr).unwrap();
21-
eprint!("{}{}", stdout, stderr);
21+
eprint!("{stdout}{stderr}");
2222
panic!("generate_self_schema.py failed with {}", output.status);
2323
}
2424
}

src/build_tools.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl SchemaError {
135135
match error {
136136
ValError::LineErrors(line_errors) => {
137137
let details = pretty_line_errors(py, line_errors);
138-
SchemaError::new_err(format!("Invalid Schema:\n{}", details))
138+
SchemaError::new_err(format!("Invalid Schema:\n{details}"))
139139
}
140140
ValError::InternalErr(py_err) => py_err,
141141
ValError::Omit => unreachable!(),
@@ -151,7 +151,7 @@ impl SchemaError {
151151
}
152152

153153
fn __repr__(&self) -> String {
154-
format!("{:?}", self)
154+
format!("{self:?}")
155155
}
156156

157157
fn __str__(&self) -> String {

src/errors/kinds.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,9 @@ impl FromPyObject<'_> for Number {
638638
impl fmt::Display for Number {
639639
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
640640
match self {
641-
Self::Float(s) => write!(f, "{}", s),
642-
Self::Int(i) => write!(f, "{}", i),
643-
Self::String(s) => write!(f, "{}", s),
641+
Self::Float(s) => write!(f, "{s}"),
642+
Self::Int(i) => write!(f, "{i}"),
643+
Self::String(s) => write!(f, "{s}"),
644644
}
645645
}
646646
}

src/errors/location.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub enum LocItem {
1717
impl fmt::Display for LocItem {
1818
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1919
match self {
20-
Self::S(s) => write!(f, "{}", s),
21-
Self::I(i) => write!(f, "{}", i),
20+
Self::S(s) => write!(f, "{s}"),
21+
Self::I(i) => write!(f, "{i}"),
2222
}
2323
}
2424
}

src/errors/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ pub fn py_err_string(py: Python, err: PyErr) -> String {
2020
let str_cow = py_str.to_string_lossy();
2121
let str = str_cow.as_ref();
2222
if !str.is_empty() {
23-
format!("{}: {}", type_name, str)
23+
format!("{type_name}: {str}")
2424
} else {
2525
type_name.to_string()
2626
}
2727
}
28-
Err(_) => format!("{}: <exception str() failed>", type_name),
28+
Err(_) => format!("{type_name}: <exception str() failed>"),
2929
},
3030
Err(_) => "Unknown Error".to_string(),
3131
}

src/errors/validation_exception.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl ValidationError {
4545
let plural = if count == 1 { "" } else { "s" };
4646
let title: &str = self.title.extract(py).unwrap();
4747
let line_errors = pretty_py_line_errors(py, self.line_errors.iter());
48-
format!("{} validation error{} for {}\n{}", count, plural, title, line_errors)
48+
format!("{count} validation error{plural} for {title}\n{line_errors}")
4949
}
5050

5151
pub fn omit_error() -> PyErr {
@@ -117,7 +117,7 @@ pub fn pretty_py_line_errors<'a>(py: Python, line_errors_iter: impl Iterator<Ite
117117
line_errors_iter
118118
.map(|i| i.pretty(py))
119119
.collect::<Result<Vec<_>, _>>()
120-
.unwrap_or_else(|err| vec![format!("[error formatting line errors: {}]", err)])
120+
.unwrap_or_else(|err| vec![format!("[error formatting line errors: {err}]")])
121121
.join("\n")
122122
}
123123

@@ -173,9 +173,9 @@ impl PyLineError {
173173

174174
let message = match self.kind.render_message(py) {
175175
Ok(message) => message,
176-
Err(err) => format!("(error rendering message: {})", err),
176+
Err(err) => format!("(error rendering message: {err})"),
177177
};
178-
write!(output, " {} [kind={}", message, self.kind.kind())?;
178+
write!(output, " {message} [kind={}", self.kind.kind())?;
179179

180180
let input_value = self.input_value.as_ref(py);
181181
let input_str = match repr_string(input_value) {
@@ -185,7 +185,7 @@ impl PyLineError {
185185
truncate_input_value!(output, input_str);
186186

187187
if let Ok(type_) = input_value.get_type().name() {
188-
write!(output, ", input_type={}", type_)?;
188+
write!(output, ", input_type={type_}")?;
189189
}
190190
output.push(']');
191191
Ok(output)

src/errors/value_exception.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ impl PydanticCustomError {
8585
fn __repr__(&self, py: Python) -> PyResult<String> {
8686
let msg = self.message(py)?;
8787
match { self.context.as_ref() } {
88-
Some(ctx) => Ok(format!("{} [kind={}, context={}]", msg, self.kind, ctx.as_ref(py))),
89-
None => Ok(format!("{} [kind={}, context=None]", msg, self.kind)),
88+
Some(ctx) => Ok(format!("{msg} [kind={}, context={}]", self.kind, ctx.as_ref(py))),
89+
None => Ok(format!("{msg} [kind={}, context=None]", self.kind)),
9090
}
9191
}
9292
}
@@ -138,8 +138,8 @@ impl PydanticKindError {
138138
fn __repr__(&self, py: Python) -> PyResult<String> {
139139
let msg = self.message(py)?;
140140
match { self.context(py)?.as_ref() } {
141-
Some(ctx) => Ok(format!("{} [kind={}, context={}]", msg, self.kind(), ctx.as_ref(py))),
142-
None => Ok(format!("{} [kind={}, context=None]", msg, self.kind())),
141+
Some(ctx) => Ok(format!("{msg} [kind={}, context={}]", self.kind(), ctx.as_ref(py))),
142+
None => Ok(format!("{msg} [kind={}, context=None]", self.kind())),
143143
}
144144
}
145145
}

src/input/input_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl<'a> Input<'a> for JsonInput {
2525
match self {
2626
JsonInput::Int(i) => LocItem::I(*i as usize),
2727
JsonInput::String(s) => s.as_str().into(),
28-
v => format!("{:?}", v).into(),
28+
v => format!("{v:?}").into(),
2929
}
3030
}
3131

src/input/input_python.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'a> Input<'a> for PyAny {
6868
} else {
6969
match repr_string(self) {
7070
Ok(s) => s.into(),
71-
Err(_) => format!("{:?}", self).into(),
71+
Err(_) => format!("{self:?}").into(),
7272
}
7373
}
7474
}

0 commit comments

Comments
 (0)