Skip to content

Commit 86bf7aa

Browse files
authored
chore:clippy (#113)
1 parent b565ccf commit 86bf7aa

File tree

4 files changed

+34
-40
lines changed

4 files changed

+34
-40
lines changed

python/src/thread_pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static DEFAULT_POOL: GILOnceCell<Arc<ThreadPool>> = GILOnceCell::new();
1111
pub fn get_default_pool(py: Python<'_>) -> PyResult<Arc<ThreadPool>> {
1212
let runtime = DEFAULT_POOL.get_or_try_init(py, || {
1313
let pool = ThreadPoolBuilder::new().build().map_err(|err| {
14-
PyValueError::new_err(format!("Could not create rayon threadpool. {}", err))
14+
PyValueError::new_err(format!("Could not create rayon threadpool. {err}"))
1515
})?;
1616
Ok::<_, PyErr>(Arc::new(pool))
1717
})?;
@@ -29,7 +29,7 @@ impl PyThreadPool {
2929
.num_threads(num_threads)
3030
.build()
3131
.map_err(|err| {
32-
PyValueError::new_err(format!("Could not create rayon threadpool. {}", err))
32+
PyValueError::new_err(format!("Could not create rayon threadpool. {err}"))
3333
})?;
3434
Ok(Self(Arc::new(pool)))
3535
}

python/src/tiff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl PyTIFF {
6565
.ifds()
6666
.as_ref()
6767
.get(z)
68-
.ok_or_else(|| PyIndexError::new_err(format!("No IFD found for z={}", z)))?
68+
.ok_or_else(|| PyIndexError::new_err(format!("No IFD found for z={z}")))?
6969
// TODO: avoid this clone; add Arc to underlying rust code?
7070
.clone();
7171
future_into_py(py, async move {
@@ -91,7 +91,7 @@ impl PyTIFF {
9191
.ifds()
9292
.as_ref()
9393
.get(z)
94-
.ok_or_else(|| PyIndexError::new_err(format!("No IFD found for z={}", z)))?
94+
.ok_or_else(|| PyIndexError::new_err(format!("No IFD found for z={z}")))?
9595
// TODO: avoid this clone; add Arc to underlying rust code?
9696
.clone();
9797
future_into_py(py, async move {

python/src/value.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ impl<'py> IntoPyObject<'py> for PyValue {
3535
Value::Ifd(_val) => Err(PyRuntimeError::new_err("Unsupported value type 'Ifd'")),
3636
Value::IfdBig(_val) => Err(PyRuntimeError::new_err("Unsupported value type 'IfdBig'")),
3737
v => Err(PyRuntimeError::new_err(format!(
38-
"Unknown value type: {:?}",
39-
v
38+
"Unknown value type: {v:?}"
4039
))),
4140
}
4241
}

src/tiff/error.rs

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ impl fmt::Display for TiffFormatError {
9191
} => {
9292
write!(
9393
fmt,
94-
"Decompression returned different amount of bytes than expected: got {}, expected {}.",
95-
actual_bytes, required_bytes
94+
"Decompression returned different amount of bytes than expected: got {actual_bytes}, expected {required_bytes}."
9695
)
9796
}
9897
InconsistentStripSamples {
@@ -101,37 +100,36 @@ impl fmt::Display for TiffFormatError {
101100
} => {
102101
write!(
103102
fmt,
104-
"Inconsistent elements in strip: got {}, expected {}.",
105-
actual_samples, required_samples
103+
"Inconsistent elements in strip: got {actual_samples}, expected {required_samples}."
106104
)
107105
}
108-
InvalidDimensions(width, height) => write!(fmt, "Invalid dimensions: {}x{}.", width, height),
106+
InvalidDimensions(width, height) => write!(fmt, "Invalid dimensions: {width}x{height}."),
109107
InvalidTag => write!(fmt, "Image contains invalid tag."),
110108
InvalidTagValueType(ref tag) => {
111-
write!(fmt, "Tag `{:?}` did not have the expected value type.", tag)
109+
write!(fmt, "Tag `{tag:?}` did not have the expected value type.")
112110
}
113-
RequiredTagNotFound(ref tag) => write!(fmt, "Required tag `{:?}` not found.", tag),
111+
RequiredTagNotFound(ref tag) => write!(fmt, "Required tag `{tag:?}` not found."),
114112
UnknownPredictor(ref predictor) => {
115-
write!(fmt, "Unknown predictor “{}” encountered", predictor)
113+
write!(fmt, "Unknown predictor “{predictor}” encountered")
116114
}
117115
UnknownPlanarConfiguration(ref planar_config) => {
118-
write!(fmt, "Unknown planar configuration “{}” encountered", planar_config)
116+
write!(fmt, "Unknown planar configuration “{planar_config}” encountered")
119117
}
120-
ByteExpected(ref val) => write!(fmt, "Expected byte, {:?} found.", val),
121-
SignedByteExpected(ref val) => write!(fmt, "Expected signed byte, {:?} found.", val),
122-
ShortExpected(ref val) => write!(fmt, "Expected short, {:?} found.", val),
123-
SignedShortExpected(ref val) => write!(fmt, "Expected signed short, {:?} found.", val),
118+
ByteExpected(ref val) => write!(fmt, "Expected byte, {val:?} found."),
119+
SignedByteExpected(ref val) => write!(fmt, "Expected signed byte, {val:?} found."),
120+
ShortExpected(ref val) => write!(fmt, "Expected short, {val:?} found."),
121+
SignedShortExpected(ref val) => write!(fmt, "Expected signed short, {val:?} found."),
124122
UnsignedIntegerExpected(ref val) => {
125-
write!(fmt, "Expected unsigned integer, {:?} found.", val)
123+
write!(fmt, "Expected unsigned integer, {val:?} found.")
126124
}
127125
SignedIntegerExpected(ref val) => {
128-
write!(fmt, "Expected signed integer, {:?} found.", val)
126+
write!(fmt, "Expected signed integer, {val:?} found.")
129127
}
130-
Format(ref val) => write!(fmt, "Invalid format: {:?}.", val),
131-
RequiredTagEmpty(ref val) => write!(fmt, "Required tag {:?} was empty.", val),
128+
Format(ref val) => write!(fmt, "Invalid format: {val:?}."),
129+
RequiredTagEmpty(ref val) => write!(fmt, "Required tag {val:?} was empty."),
132130
StripTileTagConflict => write!(fmt, "File should contain either (StripByteCounts and StripOffsets) or (TileByteCounts and TileOffsets), other combination was found."),
133131
CycleInOffsets => write!(fmt, "File contained a cycle in the list of IFDs"),
134-
JpegDecoder(ref error) => write!(fmt, "{}", error),
132+
JpegDecoder(ref error) => write!(fmt, "{error}"),
135133
SamplesPerPixelIsZero => write!(fmt, "Samples per pixel is zero"),
136134
}
137135
}
@@ -182,49 +180,47 @@ impl fmt::Display for TiffUnsupportedError {
182180
// color_type
183181
// ),
184182
InconsistentBitsPerSample(ref bits_per_sample) => {
185-
write!(fmt, "Inconsistent bits per sample: {:?}.", bits_per_sample)
183+
write!(fmt, "Inconsistent bits per sample: {bits_per_sample:?}.")
186184
}
187185
InterpretationWithBits(ref photometric_interpretation, ref bits_per_sample) => write!(
188186
fmt,
189-
"{:?} with {:?} bits per sample is unsupported",
190-
photometric_interpretation, bits_per_sample
187+
"{photometric_interpretation:?} with {bits_per_sample:?} bits per sample is unsupported"
191188
),
192189
UnknownInterpretation => write!(
193190
fmt,
194191
"The image is using an unknown photometric interpretation."
195192
),
196193
UnknownCompressionMethod => write!(fmt, "Unknown compression method."),
197194
UnsupportedCompressionMethod(method) => {
198-
write!(fmt, "Compression method {:?} is unsupported", method)
195+
write!(fmt, "Compression method {method:?} is unsupported")
199196
}
200197
UnsupportedPredictor(p) => {
201198
write!(fmt, "Predictor {p:?} is unsupported")
202199
}
203200
UnsupportedSampleDepth(samples) => {
204-
write!(fmt, "{} samples per pixel is unsupported.", samples)
201+
write!(fmt, "{samples} samples per pixel is unsupported.")
205202
}
206203
UnsupportedSampleFormat(ref formats) => {
207-
write!(fmt, "Sample format {:?} is unsupported.", formats)
204+
write!(fmt, "Sample format {formats:?} is unsupported.")
208205
}
209206
// UnsupportedColorType(color_type) => {
210207
// write!(fmt, "Color type {:?} is unsupported", color_type)
211208
// }
212209
UnsupportedBitsPerChannel(bits) => {
213-
write!(fmt, "{} bits per channel not supported", bits)
210+
write!(fmt, "{bits} bits per channel not supported")
214211
}
215212
UnsupportedPlanarConfig(config) => {
216-
write!(fmt, "Unsupported planar configuration “{:?}”.", config)
213+
write!(fmt, "Unsupported planar configuration “{config:?}”.")
217214
}
218215
UnsupportedDataType => write!(fmt, "Unsupported data type."),
219216
UnsupportedInterpretation(interpretation) => {
220217
write!(
221218
fmt,
222-
"Unsupported photometric interpretation \"{:?}\".",
223-
interpretation
219+
"Unsupported photometric interpretation \"{interpretation:?}\"."
224220
)
225221
}
226222
UnsupportedJpegFeature(ref unsupported_feature) => {
227-
write!(fmt, "Unsupported JPEG feature {:?}", unsupported_feature)
223+
write!(fmt, "Unsupported JPEG feature {unsupported_feature:?}")
228224
}
229225
MisalignedTileBoundaries => write!(fmt, "Tile rows are not aligned to byte boundaries"),
230226
}
@@ -254,7 +250,7 @@ impl fmt::Display for UsageError {
254250
// expected, actual
255251
// )
256252
// }
257-
InvalidChunkIndex(index) => write!(fmt, "Image chunk index ({}) requested.", index),
253+
InvalidChunkIndex(index) => write!(fmt, "Image chunk index ({index}) requested."),
258254
PredictorCompressionMismatch => write!(
259255
fmt,
260256
"The requested predictor is not compatible with the requested compression"
@@ -271,16 +267,15 @@ impl fmt::Display for UsageError {
271267
impl fmt::Display for TiffError {
272268
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
273269
match *self {
274-
TiffError::FormatError(ref e) => write!(fmt, "Format error: {}", e),
270+
TiffError::FormatError(ref e) => write!(fmt, "Format error: {e}"),
275271
TiffError::UnsupportedError(ref f) => write!(
276272
fmt,
277273
"The Decoder does not support the \
278-
image format `{}`",
279-
f
274+
image format `{f}`"
280275
),
281276
TiffError::IoError(ref e) => e.fmt(fmt),
282277
TiffError::IntSizeError => write!(fmt, "Platform or format size limits exceeded"),
283-
TiffError::UsageError(ref e) => write!(fmt, "Usage error: {}", e),
278+
TiffError::UsageError(ref e) => write!(fmt, "Usage error: {e}"),
284279
}
285280
}
286281
}

0 commit comments

Comments
 (0)