From 5e32e2a6d3cb569499f4e2cc94856659cd628357 Mon Sep 17 00:00:00 2001 From: samwelkanda Date: Mon, 28 Nov 2022 13:27:58 +0300 Subject: [PATCH 1/2] Switch from hardcoded to dynamic error module names --- src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs | 2 +- .../Writers/Python/CodeMethodWriterTests.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs index d746ea7c26..529f10e243 100644 --- a/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs @@ -289,7 +289,7 @@ private void WriteRequestExecutorBody(CodeMethod codeElement, RequestParams requ writer.WriteLine($"{errorMappingVarName}: Dict[str, ParsableFactory] = {{"); writer.IncreaseIndent(); foreach(var errorMapping in codeElement.ErrorMappings) { - writer.WriteLine($"\"{errorMapping.Key.ToUpperInvariant()}\": o_data_error.{errorMapping.Value.Name},"); + writer.WriteLine($"\"{errorMapping.Key.ToUpperInvariant()}\": {errorMapping.Value.Name.ToSnakeCase()}.{errorMapping.Value.Name},"); } writer.CloseBlock(); } diff --git a/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs index 97186d32e6..8c149d155b 100644 --- a/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs @@ -233,9 +233,9 @@ public void WritesRequestExecutorBody() { var result = tw.ToString(); Assert.Contains("request_info", result); Assert.Contains("error_mapping: Dict[str, ParsableFactory] =", result); - Assert.Contains("\"4XX\": o_data_error.Error4XX", result); - Assert.Contains("\"5XX\": o_data_error.Error5XX", result); - Assert.Contains("\"403\": o_data_error.Error403", result); + Assert.Contains("\"4XX\": error4_x_x.Error4XX", result); + Assert.Contains("\"5XX\": error5_x_x.Error5XX", result); + Assert.Contains("\"403\": error403.Error403", result); Assert.Contains("send_async", result); Assert.Contains("raise Exception", result); } From f0a48f2b3fe2e16aff42606081329b96daba4d18 Mon Sep 17 00:00:00 2001 From: samwelkanda Date: Mon, 28 Nov 2022 13:30:24 +0300 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b648846a56..3b68eba3e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed a bug where request information would always be set from scalar. [#1965](https://github.com/microsoft/kiota/pull/1965) - Fixed a bug where path parameters would be missing if no operation was present at the segment the parameter is defined. [#1940](https://github.com/microsoft/kiota/issues/1940) - Fixed a bug where generation would result in wrong indentation in some classes for Python [#1996]((https://github.com/microsoft/kiota/issues/1996). +- Fixed a bug where error class modules were hardcoded for Python [#1999]((https://github.com/microsoft/kiota/issues/1999) ## [0.7.1] - 2022-11-01