Fix Python namespace normalization during refinement#7991
Open
AayushP123 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes Python namespace normalization at the CodeDOM refinement stage by ensuring namespace segments are converted to snake_case during refinement (including proper traversal from the root namespace) and by normalizing the configured client namespace prefix before Python path/import logic computes namespace differentials.
Changes:
- Normalize Python
CodeNamespace.Namesegments tosnake_caseduringPythonRefiner.RefineAsync, ensuring traversal starts from the root namespace. - Normalize
clientNamespaceNametosnake_caseinsidePythonWriterbefore initializing the path segmenter and namespace-dependent writers. - Update and extend tests to validate refined namespace casing, writer prefix normalization behavior, and public API export expectations.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Kiota.Builder/Refiners/PythonRefiner.cs |
Adds a refinement pass to snake_case namespace segments and ensures traversal runs from the root namespace. |
src/Kiota.Builder/Writers/Python/PythonWriter.cs |
Normalizes the configured client namespace prefix to snake_case before path/import computations. |
tests/Kiota.Builder.Tests/Refiners/PythonLanguageRefinerTests.cs |
Adds coverage asserting namespace segment snake_casing and namespace lookup consistency post-refinement. |
tests/Kiota.Builder.Tests/Writers/Python/PythonWriterTests.cs |
Adds coverage ensuring client namespace prefix normalization affects path segmentation as expected. |
tests/Kiota.Builder.Tests/Export/PublicAPIExportServiceTests.cs |
Updates expected Python export namespace strings to reflect refined snake_case namespace names. |
tests/Kiota.Builder.Tests/KiotaBuilderTests.cs |
Updates a namespace lookup expectation for Python to match snake_cased namespaces after refinement. |
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
Normalizes Python CodeDOM namespace segments to snake_case during language refinement. Normalizes the configured client namespace before path and import writers calculate namespace differentials. Updates public API export expectations and adds coverage for root traversal and configured namespace casing.
Validation
dotnet test tests/Kiota.Builder.Tests/Kiota.Builder.Tests.csproj --no-restore --nologo --filter 'FullyQualifiedName!~KiotaSearcherTests' --verbosity quiet(2,185 passed, 2 skipped)Focused Python namespace, writer, export, and builder tests: 41 passed.
Fixes #7715