Skip to content

chore:clippy #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2025
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
4 changes: 2 additions & 2 deletions python/src/thread_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static DEFAULT_POOL: GILOnceCell<Arc<ThreadPool>> = GILOnceCell::new();
pub fn get_default_pool(py: Python<'_>) -> PyResult<Arc<ThreadPool>> {
let runtime = DEFAULT_POOL.get_or_try_init(py, || {
let pool = ThreadPoolBuilder::new().build().map_err(|err| {
PyValueError::new_err(format!("Could not create rayon threadpool. {}", err))
PyValueError::new_err(format!("Could not create rayon threadpool. {err}"))
})?;
Ok::<_, PyErr>(Arc::new(pool))
})?;
Expand All @@ -29,7 +29,7 @@ impl PyThreadPool {
.num_threads(num_threads)
.build()
.map_err(|err| {
PyValueError::new_err(format!("Could not create rayon threadpool. {}", err))
PyValueError::new_err(format!("Could not create rayon threadpool. {err}"))
})?;
Ok(Self(Arc::new(pool)))
}
Expand Down
4 changes: 2 additions & 2 deletions python/src/tiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl PyTIFF {
.ifds()
.as_ref()
.get(z)
.ok_or_else(|| PyIndexError::new_err(format!("No IFD found for z={}", z)))?
.ok_or_else(|| PyIndexError::new_err(format!("No IFD found for z={z}")))?
// TODO: avoid this clone; add Arc to underlying rust code?
.clone();
future_into_py(py, async move {
Expand All @@ -91,7 +91,7 @@ impl PyTIFF {
.ifds()
.as_ref()
.get(z)
.ok_or_else(|| PyIndexError::new_err(format!("No IFD found for z={}", z)))?
.ok_or_else(|| PyIndexError::new_err(format!("No IFD found for z={z}")))?
// TODO: avoid this clone; add Arc to underlying rust code?
.clone();
future_into_py(py, async move {
Expand Down
3 changes: 1 addition & 2 deletions python/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ impl<'py> IntoPyObject<'py> for PyValue {
Value::Ifd(_val) => Err(PyRuntimeError::new_err("Unsupported value type 'Ifd'")),
Value::IfdBig(_val) => Err(PyRuntimeError::new_err("Unsupported value type 'IfdBig'")),
v => Err(PyRuntimeError::new_err(format!(
"Unknown value type: {:?}",
v
"Unknown value type: {v:?}"
))),
}
}
Expand Down
63 changes: 29 additions & 34 deletions src/tiff/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ impl fmt::Display for TiffFormatError {
} => {
write!(
fmt,
"Decompression returned different amount of bytes than expected: got {}, expected {}.",
actual_bytes, required_bytes
"Decompression returned different amount of bytes than expected: got {actual_bytes}, expected {required_bytes}."
)
}
InconsistentStripSamples {
Expand All @@ -101,37 +100,36 @@ impl fmt::Display for TiffFormatError {
} => {
write!(
fmt,
"Inconsistent elements in strip: got {}, expected {}.",
actual_samples, required_samples
"Inconsistent elements in strip: got {actual_samples}, expected {required_samples}."
)
}
InvalidDimensions(width, height) => write!(fmt, "Invalid dimensions: {}x{}.", width, height),
InvalidDimensions(width, height) => write!(fmt, "Invalid dimensions: {width}x{height}."),
InvalidTag => write!(fmt, "Image contains invalid tag."),
InvalidTagValueType(ref tag) => {
write!(fmt, "Tag `{:?}` did not have the expected value type.", tag)
write!(fmt, "Tag `{tag:?}` did not have the expected value type.")
}
RequiredTagNotFound(ref tag) => write!(fmt, "Required tag `{:?}` not found.", tag),
RequiredTagNotFound(ref tag) => write!(fmt, "Required tag `{tag:?}` not found."),
UnknownPredictor(ref predictor) => {
write!(fmt, "Unknown predictor “{}” encountered", predictor)
write!(fmt, "Unknown predictor “{predictor}” encountered")
}
UnknownPlanarConfiguration(ref planar_config) => {
write!(fmt, "Unknown planar configuration “{}” encountered", planar_config)
write!(fmt, "Unknown planar configuration “{planar_config}” encountered")
}
ByteExpected(ref val) => write!(fmt, "Expected byte, {:?} found.", val),
SignedByteExpected(ref val) => write!(fmt, "Expected signed byte, {:?} found.", val),
ShortExpected(ref val) => write!(fmt, "Expected short, {:?} found.", val),
SignedShortExpected(ref val) => write!(fmt, "Expected signed short, {:?} found.", val),
ByteExpected(ref val) => write!(fmt, "Expected byte, {val:?} found."),
SignedByteExpected(ref val) => write!(fmt, "Expected signed byte, {val:?} found."),
ShortExpected(ref val) => write!(fmt, "Expected short, {val:?} found."),
SignedShortExpected(ref val) => write!(fmt, "Expected signed short, {val:?} found."),
UnsignedIntegerExpected(ref val) => {
write!(fmt, "Expected unsigned integer, {:?} found.", val)
write!(fmt, "Expected unsigned integer, {val:?} found.")
}
SignedIntegerExpected(ref val) => {
write!(fmt, "Expected signed integer, {:?} found.", val)
write!(fmt, "Expected signed integer, {val:?} found.")
}
Format(ref val) => write!(fmt, "Invalid format: {:?}.", val),
RequiredTagEmpty(ref val) => write!(fmt, "Required tag {:?} was empty.", val),
Format(ref val) => write!(fmt, "Invalid format: {val:?}."),
RequiredTagEmpty(ref val) => write!(fmt, "Required tag {val:?} was empty."),
StripTileTagConflict => write!(fmt, "File should contain either (StripByteCounts and StripOffsets) or (TileByteCounts and TileOffsets), other combination was found."),
CycleInOffsets => write!(fmt, "File contained a cycle in the list of IFDs"),
JpegDecoder(ref error) => write!(fmt, "{}", error),
JpegDecoder(ref error) => write!(fmt, "{error}"),
SamplesPerPixelIsZero => write!(fmt, "Samples per pixel is zero"),
}
}
Expand Down Expand Up @@ -182,49 +180,47 @@ impl fmt::Display for TiffUnsupportedError {
// color_type
// ),
InconsistentBitsPerSample(ref bits_per_sample) => {
write!(fmt, "Inconsistent bits per sample: {:?}.", bits_per_sample)
write!(fmt, "Inconsistent bits per sample: {bits_per_sample:?}.")
}
InterpretationWithBits(ref photometric_interpretation, ref bits_per_sample) => write!(
fmt,
"{:?} with {:?} bits per sample is unsupported",
photometric_interpretation, bits_per_sample
"{photometric_interpretation:?} with {bits_per_sample:?} bits per sample is unsupported"
),
UnknownInterpretation => write!(
fmt,
"The image is using an unknown photometric interpretation."
),
UnknownCompressionMethod => write!(fmt, "Unknown compression method."),
UnsupportedCompressionMethod(method) => {
write!(fmt, "Compression method {:?} is unsupported", method)
write!(fmt, "Compression method {method:?} is unsupported")
}
UnsupportedPredictor(p) => {
write!(fmt, "Predictor {p:?} is unsupported")
}
UnsupportedSampleDepth(samples) => {
write!(fmt, "{} samples per pixel is unsupported.", samples)
write!(fmt, "{samples} samples per pixel is unsupported.")
}
UnsupportedSampleFormat(ref formats) => {
write!(fmt, "Sample format {:?} is unsupported.", formats)
write!(fmt, "Sample format {formats:?} is unsupported.")
}
// UnsupportedColorType(color_type) => {
// write!(fmt, "Color type {:?} is unsupported", color_type)
// }
UnsupportedBitsPerChannel(bits) => {
write!(fmt, "{} bits per channel not supported", bits)
write!(fmt, "{bits} bits per channel not supported")
}
UnsupportedPlanarConfig(config) => {
write!(fmt, "Unsupported planar configuration “{:?}”.", config)
write!(fmt, "Unsupported planar configuration “{config:?}”.")
}
UnsupportedDataType => write!(fmt, "Unsupported data type."),
UnsupportedInterpretation(interpretation) => {
write!(
fmt,
"Unsupported photometric interpretation \"{:?}\".",
interpretation
"Unsupported photometric interpretation \"{interpretation:?}\"."
)
}
UnsupportedJpegFeature(ref unsupported_feature) => {
write!(fmt, "Unsupported JPEG feature {:?}", unsupported_feature)
write!(fmt, "Unsupported JPEG feature {unsupported_feature:?}")
}
MisalignedTileBoundaries => write!(fmt, "Tile rows are not aligned to byte boundaries"),
}
Expand Down Expand Up @@ -254,7 +250,7 @@ impl fmt::Display for UsageError {
// expected, actual
// )
// }
InvalidChunkIndex(index) => write!(fmt, "Image chunk index ({}) requested.", index),
InvalidChunkIndex(index) => write!(fmt, "Image chunk index ({index}) requested."),
PredictorCompressionMismatch => write!(
fmt,
"The requested predictor is not compatible with the requested compression"
Expand All @@ -271,16 +267,15 @@ impl fmt::Display for UsageError {
impl fmt::Display for TiffError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
TiffError::FormatError(ref e) => write!(fmt, "Format error: {}", e),
TiffError::FormatError(ref e) => write!(fmt, "Format error: {e}"),
TiffError::UnsupportedError(ref f) => write!(
fmt,
"The Decoder does not support the \
image format `{}`",
f
image format `{f}`"
),
TiffError::IoError(ref e) => e.fmt(fmt),
TiffError::IntSizeError => write!(fmt, "Platform or format size limits exceeded"),
TiffError::UsageError(ref e) => write!(fmt, "Usage error: {}", e),
TiffError::UsageError(ref e) => write!(fmt, "Usage error: {e}"),
}
}
}
Expand Down