-
Notifications
You must be signed in to change notification settings - Fork 375
[WIP] fix(http-client-python): coerce string boolean args in run_batch.py #10566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
edc40cf
fix(http-client-python): coerce string boolean args in run_batch.py
invalid-email-address 3bbb589
test: guard regenerated packages emit pyproject.toml; reset pygen glo…
invalid-email-address 27fcec9
fix(http-client-python): make pygen package-file lists per-instance
invalid-email-address a6160d7
fix(http-client-python): fix resiliency tests and show failed tests i…
9111187
skip test_put_model_property pending serialization fix
6d29274
fix(http-client-python): handle non-constant api_version from TCGC
9efaa4f
fix(http-client-python): detect api_version in endpoint template params
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
.chronus/changes/fix-keep-setup-py-coercion-2026-4-30-5-30-0.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: internal | ||
| packages: | ||
| - "@typespec/http-client-python" | ||
| --- | ||
|
|
||
| Fix `run_batch.py` passing string `"true"`/`"false"` values to pygen, which caused `keep-setup-py="false"` to be treated as truthy and generate `setup.py` instead of `pyproject.toml` for all regenerated test packages. |
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
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
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
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
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
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
65 changes: 65 additions & 0 deletions
65
packages/http-client-python/tests/unit/test_generated_packaging_files.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| """Verify regenerated test packages emit pyproject.toml, not setup.py. | ||
|
|
||
| The Python emitter passes options to pygen via JSON config files. Boolean | ||
| flags arrive as the strings "true"/"false". If those strings are not coerced | ||
| to real booleans before being unpacked as kwargs to pygen, a value like | ||
| keep-setup-py="false" is treated as truthy in Python and pygen emits | ||
| setup.py instead of pyproject.toml. This test guards against that | ||
| regression by walking the regenerated test fixtures. | ||
| """ | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| # Packages that intentionally opt into setup.py via keep-setup-py=true in | ||
| # eng/scripts/ci/regenerate.ts. They should have setup.py and no pyproject.toml. | ||
| KEEP_SETUP_PY_PACKAGES = {"setuppy-authentication-union"} | ||
|
|
||
| _GENERATED_ROOT = Path(__file__).resolve().parents[1] / "generated" | ||
|
|
||
|
|
||
| def _iter_generated_packages(): | ||
| if not _GENERATED_ROOT.is_dir(): | ||
| return | ||
| for flavor_dir in sorted(_GENERATED_ROOT.iterdir()): | ||
| if not flavor_dir.is_dir(): | ||
| continue | ||
| for pkg_dir in sorted(flavor_dir.iterdir()): | ||
| if not pkg_dir.is_dir(): | ||
| continue | ||
| yield flavor_dir.name, pkg_dir | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "flavor,pkg_dir", | ||
| list(_iter_generated_packages()), | ||
| ids=lambda v: v.name if isinstance(v, Path) else v, | ||
| ) | ||
| def test_generated_package_uses_pyproject_toml(flavor, pkg_dir): | ||
| has_setup_py = (pkg_dir / "setup.py").is_file() | ||
| has_pyproject = (pkg_dir / "pyproject.toml").is_file() | ||
|
|
||
| if pkg_dir.name in KEEP_SETUP_PY_PACKAGES: | ||
| assert has_setup_py, f"{flavor}/{pkg_dir.name} should have setup.py (keep-setup-py=true)" | ||
| assert not has_pyproject, ( | ||
| f"{flavor}/{pkg_dir.name} should NOT have pyproject.toml (keep-setup-py=true)" | ||
| ) | ||
| return | ||
|
|
||
| assert has_pyproject, ( | ||
| f"{flavor}/{pkg_dir.name} is missing pyproject.toml. " | ||
| f"This usually means string boolean args (e.g. keep-setup-py=\"false\") " | ||
| f"were not coerced to real booleans before being passed to pygen. " | ||
| f"See eng/scripts/setup/run_batch.py." | ||
| ) | ||
| assert not has_setup_py, ( | ||
| f"{flavor}/{pkg_dir.name} has setup.py but should use pyproject.toml. " | ||
| f"This usually means string boolean args (e.g. keep-setup-py=\"false\") " | ||
| f"were not coerced to real booleans before being passed to pygen. " | ||
| f"See eng/scripts/setup/run_batch.py." | ||
| ) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.