[python] Fix import for generation-subdir#10303
Merged
Conversation
commit: |
Contributor
|
All changed packages have been documented.
Show changes
|
Collaborator
|
You can try these changes here
|
6dc7451 to
34539c7
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Python emitter import generation when generation-subdir is used so that generated code in subdirectories can correctly resolve shared modules like _validation.py and _types.py.
Changes:
- Write
_validation.pyand_types.pyinto thegeneration-subdiroutput directory to match where operation/client code is generated. - Extend CI regeneration scripts/config to generate additional
generation-subdirtest packages and add a sharedpreprocess()helper. - Add new sync/async mock-api tests that import and exercise generated clients under
generation.<subdir>._generated.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/http-client-python/generator/pygen/codegen/serializers/init.py | Writes _validation.py / _types.py into generation_dir to fix relative imports under generation-subdir. |
| packages/http-client-python/eng/scripts/ci/regenerate.ts | Switches to shared preprocess() and trims local emitter options. |
| packages/http-client-python/eng/scripts/ci/regenerate-common.ts | Adds multi-output emitter configs (arrays) for new generation-subdir scenarios; introduces shared preprocess(). |
| packages/http-client-python/tests/mock_api/shared/test_generation_subdir_for_generated_code.py | New sync test covering generated code under generation-subdir. |
| packages/http-client-python/tests/mock_api/shared/test_generation_subdir2_for_generated_code.py | New sync test validating _validation.py / _types.py usage under generation-subdir. |
| packages/http-client-python/tests/mock_api/shared/asynctests/test_generation_subdir_for_generated_code_async.py | Async variant of generation-subdir coverage. |
| packages/http-client-python/tests/mock_api/shared/asynctests/test_generation_subdir2_for_generated_code_async.py | Async variant validating _validation.py / _types.py under generation-subdir. |
| packages/http-client-python/tests/conftest.py | Suppresses mock server output during tests. |
| packages/http-client-python/tests/mock_api/unbranded/test_unbranded.py | Removes the “microsoft” sensitive-word assertion from generated unbranded outputs. |
| .chronus/changes/fix-import-generation-subdir-2026-3-8-12-7-49.md | Adds a changelog entry for the fix. |
Comments suppressed due to low confidence (1)
packages/http-client-python/tests/mock_api/unbranded/test_unbranded.py:58
- The PR removes the "microsoft" sensitive-word assertion from
test_sensitive_word()but this change isn’t mentioned in the PR description and significantly changes what the test is validating. Please either update the PR description to cover this behavioral change (and why it’s needed) or keep an equivalent assertion (updated expected set if needed) so we still detect unexpected "microsoft" occurrences in generated unbranded outputs.
def test_sensitive_word():
check_folder = (Path(os.path.dirname(__file__)) / "../../generated/unbranded").resolve()
assert [] == check_sensitive_word(check_folder, "azure")
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ChenxiJiang333
approved these changes
Apr 9, 2026
tadelesh
approved these changes
Apr 9, 2026
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.
Description
Fix import generation when using a generation subdirectory (generation-subdir). This ensures imports are correctly resolved for generated code in subdirectories.
Changes
generator/pygen/codegen/serializers/__init__.pyregenerate-common.tsscriptChangelog