Conversation
commit: |
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
6dc7451 to
34539c7
Compare
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")
| # Suppress server stdout/stderr to avoid confusing "Request validation failed" warnings | ||
| # in test output. Server readiness is validated via HTTP polling in wait_for_server(). | ||
| if os.name == "nt": | ||
| return subprocess.Popen(cmd, shell=True, cwd=str(cwd), env=env) | ||
| return subprocess.Popen(cmd, shell=True, cwd=str(cwd), env=env, preexec_fn=os.setsid) | ||
| return subprocess.Popen(cmd, shell=True, cwd=str(cwd), env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) | ||
| return subprocess.Popen(cmd, shell=True, cwd=str(cwd), env=env, preexec_fn=os.setsid, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
There was a problem hiding this comment.
Suppressing the mock server’s stdout/stderr makes failures much harder to diagnose (e.g., if the process exits immediately, we only get an exit code without any error output). Consider redirecting output to a log file (and surfacing it on startup failures) rather than sending it to DEVNULL, so CI failures remain actionable while still keeping normal test output clean.
There was a problem hiding this comment.
I checked current log and confirm it is clean and could show enough error traceback
packages/http-client-python/eng/scripts/ci/regenerate-common.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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