Fix presubmit errors in python serialization

Change-Id: I6eaa1f64d4f5578f5858a919cfd7d46581e1c2ce
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/qg/+/121014
Commit-Queue: Erik Gilling <konkers@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/qg/src/py/ser.rs b/qg/src/py/ser.rs
index 25dc041..2c363c8 100644
--- a/qg/src/py/ser.rs
+++ b/qg/src/py/ser.rs
@@ -51,7 +51,7 @@
 
 impl ser::Error for Error {
     fn custom<T: Display>(msg: T) -> Self {
-        Error::Serialization(format!("{}", msg))
+        Error::Serialization(format!("{msg}"))
     }
 }
 
@@ -141,8 +141,12 @@
     }
 
     fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq> {
+        let values = match len {
+            Some(len) => Vec::with_capacity(len),
+            None => Vec::new(),
+        };
         Ok(Self::SerializeSeq {
-            values: Vec::with_capacity(len),
+            values,
             vm: self.vm,
         })
     }
@@ -343,7 +347,7 @@
             .ok_or_else(|| Error::custom("Value added without key"))?;
         self.dict
             .set_item(&*key, object, self.vm)
-            .map_err(|e| Error::custom(format!("Can't add key to dict: {:?}", e)))?;
+            .map_err(|e| Error::custom(format!("Can't add key to dict: {e:?}")))?;
 
         Ok(())
     }