Fix Python enum members generating tuple values#7988
Open
AayushP123 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Python enum generation so that enum members are emitted as plain string values (instead of single-element tuples), aligning the generated output with class MyEnum(str, Enum) semantics.
Changes:
- Update the Python
CodeEnumWriterto emit enum members without a trailing comma, ensuring values are strings. - Strengthen Python enum writer tests to assert the absence of the trailing comma and validate correct line termination.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Kiota.Builder/Writers/Python/CodeEnumWriter.cs | Removes the trailing comma so generated Python enum members are string literals, not tuples. |
| tests/Kiota.Builder.Tests/Writers/Python/CodeEnumWriterTests.cs | Updates assertions to verify the new string-member emission and explicitly reject the old tuple syntax. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes trailing commas from generated Python string enum assignments. Adds enum writer coverage for regular and escaped wire values.
A trailing comma makes a Python expression such as
"red",a one-element tuple, preventing incoming string values from matching generated enum members during deserialization.Validation
dotnet test tests/Kiota.Builder.Tests/Kiota.Builder.Tests.csproj --no-restore --nologo --filter 'FullyQualifiedName~Writers.Python.CodeEnumWriterTests'(11 passed)Fixes #7811