Skip to content

Fix Python namespace normalization during refinement#7991

Open
AayushP123 wants to merge 1 commit into
microsoft:mainfrom
AayushP123:codex/fix-python-namespace-casing
Open

Fix Python namespace normalization during refinement#7991
AayushP123 wants to merge 1 commit into
microsoft:mainfrom
AayushP123:codex/fix-python-namespace-casing

Conversation

@AayushP123

Copy link
Copy Markdown
Contributor

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

Copilot AI review requested due to automatic review settings July 26, 2026 07:18
@AayushP123
AayushP123 requested a review from a team as a code owner July 26, 2026 07:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Name segments to snake_case during PythonRefiner.RefineAsync, ensuring traversal starts from the root namespace.
  • Normalize clientNamespaceName to snake_case inside PythonWriter before 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: SnakeCaseNamespaceNames never executes — CrawlTree inside empty-name guard

2 participants