diff --git a/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs index f45485501b..a965b810d2 100644 --- a/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs @@ -812,8 +812,8 @@ private string GetSerializationMethodName(CodeTypeBase propType) private string GetTypeFactory(bool isVoid, bool isStream, string returnType) { if (isVoid) return string.Empty; - if (isStream || conventions.IsPrimitiveType(returnType)) return $" {returnType},"; - + if (isStream) return $" \"{returnType}\","; + if (conventions.IsPrimitiveType(returnType)) return $" {returnType},"; return $" {returnType},"; } private string GetSendRequestMethodName(bool isVoid, bool isStream, bool isCollection, string returnType, diff --git a/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs index 4f041e666d..b74c4786c4 100644 --- a/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs @@ -824,7 +824,7 @@ public void WritesUnionDeSerializerBody() } [Theory] [InlineData(true, false, "string", "")] - [InlineData(false, true, "Stream", " Stream,")] + [InlineData(false, true, "Stream", " \"Stream\",")] [InlineData(false, false, "int", " int,")] [InlineData(false, false, "CustomType", " CustomType,")] public void GetTypeFactory_ReturnsCorrectString(bool isVoid, bool isStream, string returnType, string expected)