Deduplicate changelog entries from generated types module#48109
Merged
Conversation
The TypeSpec generated 'types' module contains TypedDict input aliases that shadow the real models in the sibling 'models' module. Newly added models were therefore reported twice in the changelog (e.g. 'Added model Foo'). Add a ShadowTypesModuleChecker post-processing step that drops changelog/breaking-change entries originating from a shadow 'types' module, and add tests.
|
Azure Pipelines: Successfully started running 1 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds post-processing to deduplicate changelog entries emitted by generated types modules.
Changes:
- Adds and registers
ShadowTypesModuleChecker. - Adds tests for shadowed and standalone
typesmodules. - However, filtering is overly broad and linked issue #48107 remains unresolved.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
scripts/breaking_changes_checker/checkers/shadow_types_module_checker.py |
Filters reports from shadow types modules. |
scripts/breaking_changes_checker/supported_checkers.py |
Registers the new checker. |
scripts/breaking_changes_checker/tests/test_changelog.py |
Tests types-module cleanup behavior. |
Address review feedback: only drop a types-module entry when the sibling models module actually contains a class of the same name, so a types-only change (no models counterpart) is preserved in the breaking-change/changelog output. Add regression tests for the class-existence guard.
Only drop a types-module entry when the sibling models module reports the same change type and arguments (with member names normalized snake_case to bridge the types wire-name vs models attribute-name difference). This avoids silently dropping an unmatched types-only member change while still deduping the real property/model duplicates. Add member-level regression tests.
Compare class names and semantic values exactly and normalize only the member-name position to snake_case, avoiding false collisions on class names, type strings, or defaults. Add a regression test asserting exact class-name matching.
Pre-index sibling models match keys once so each types entry is checked with a constant-time set lookup instead of rescanning the whole change list (avoids an O(n^2) regression on large diffs). Handle list-valued change args when building keys. Add a scalability test. Also aligns the PR description with the exact class-name matching behavior.
ChenxiJiang333
approved these changes
Jul 17, 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.
Problem
When running
azpysdk breaking . --changelog --use-apistub, newly added models can appear twice in the changelog, e.g.:Root cause
TypeSpec generated libraries emit a
typesmodule (e.g.azure.mgmt.computelimit.types) containingTypedDictinput aliases that shadow the real models defined in the siblingmodelsmodule (azure.mgmt.computelimit.models). A newly added model is therefore defined in both modules, so the changelog checker reports anAddedClassfeature for each. Because theAdded model \{}`` message only uses the class name (not the module), the two entries render identically and show up as a visible duplicate.Fix
Add a
ShadowTypesModuleCheckerpost-processing step (registered inPOST_PROCESSING_CHECKERS).A
types-module entry is dropped only when the siblingmodelsmodule reports the same change — i.e. the same change type and arguments, with the module substituted. This targeted match avoids silently dropping a change that exists only on thetypesside (which would otherwise disappear from the breaking-change / changelog output).When building the match key, class names and semantic values (type strings, defaults) are compared exactly; only the member-name position is normalized to
snake_case, because thetypesTypedDicts expose wire names (e.g.serviceTreeId) while themodelsclasses expose the Python attribute names (e.g.service_tree_id). This lets a genuine member-level duplicate match across the two naming styles while preserving unmatched,types-only changes and avoiding false collisions on class names.The sibling
modelsmatch keys are indexed once so eachtypesentry is checked with an O(1) lookup (no per-entry rescans).Tests
Added tests in
tests/test_changelog.py:test_shadow_types_module_cleanup— a model added to bothmodelsandtypesis reported once (frommodels).test_shadow_types_module_kept_without_models_sibling— a standalonetypesmodule (no siblingmodels) is not stripped.test_shadow_types_module_kept_when_class_missing_in_models— atypesclass with nomodelscounterpart is preserved.test_shadow_types_module_breaking_change_preserved_for_unmatched_member— an unmatchedtypesbreaking change is preserved while a mirrored addition is deduped.test_shadow_types_module_member_change_preserved_when_not_mirrored— an unmatched member change on a class present in both modules is preserved.test_shadow_types_module_member_change_deduped_across_naming— a member change reported in both modules is deduped despite theserviceTreeIdvsservice_tree_idnaming difference.test_shadow_types_module_class_name_matched_exactly— class names are matched exactly (no snake_case normalization), so differently-named classes that would collide under normalization are not deduped.And a scalability test in
tests/test_performance.py:TestShadowTypesModuleCheckerPerformance::test_shadow_types_cleanup_performance_large— 10,000 entries are processed in well under a second (verifies the O(n) set-based lookup).Relevant suites (
test_changelog.py,test_apiview_converter.py, shadow-types perf test) pass locally: 34 passed, 1 skipped.