diff --git a/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs index fb2365e91a..5a674762d5 100644 --- a/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs @@ -647,20 +647,12 @@ private void WriteSerializerBodyForInheritedModel(bool inherits, CodeClass paren if (inherits) writer.WriteLine("super().serialize(writer)"); foreach (var otherProp in parentClass - .GetPropertiesOfKind(CodePropertyKind.Custom) - .Where(static x => !x.ExistsInBaseType && !x.ReadOnly) - .OrderBy(static x => x.Name)) + .GetPropertiesOfKind(CodePropertyKind.Custom) + .Where(static x => !x.ExistsInBaseType && !x.ReadOnly) + .OrderBy(static x => x.Name)) { var serializationMethodName = GetSerializationMethodName(otherProp.Type); - var propertyName = otherProp.Name; - writer.WriteLine($"if self.{propertyName} is not None:"); - writer.IncreaseIndent(); - writer.WriteLine($"writer.{serializationMethodName}(\"{otherProp.WireName}\", self.{propertyName})"); - writer.DecreaseIndent(); - writer.WriteLine("else:"); - writer.IncreaseIndent(); - writer.WriteLine($"writer.{serializationMethodName}(\"{otherProp.WireName}\", None)"); - writer.DecreaseIndent(); + writer.WriteLine($"writer.{serializationMethodName}(\"{NoneKeyword}\", self.{otherProp.Name})"); } } private void WriteSerializerBodyForUnionModel(CodeClass parentClass, LanguageWriter writer)