Skip to content

Commit 5807bde

Browse files
[bc] Simplify change messages (Azure#37018)
* simplify change messages * fix wording * wording * uniform msg format * wording * nit * update tests --------- Co-authored-by: Catalina Peralta <[email protected]>
1 parent fd433b0 commit 5807bde

File tree

4 files changed

+72
-82
lines changed

4 files changed

+72
-82
lines changed

scripts/breaking_changes_checker/breaking_changes_tracker.py

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,63 +36,57 @@ class BreakingChangeType(str, Enum):
3636

3737
class BreakingChangesTracker:
3838
REMOVED_OR_RENAMED_CLIENT_MSG = \
39-
"The client '{}' was deleted or renamed in the current version"
39+
"Deleted or renamed client '{}'"
4040
REMOVED_OR_RENAMED_CLIENT_METHOD_MSG = \
41-
"The '{}' client method '{}' was deleted or renamed in the current version"
41+
"Deleted or renamed client method '{}.{}'"
4242
REMOVED_OR_RENAMED_CLASS_MSG = \
43-
"The model or publicly exposed class '{}' was deleted or renamed in the current version"
43+
"Deleted or renamed model '{}'"
4444
REMOVED_OR_RENAMED_CLASS_METHOD_MSG = \
45-
"The '{}' method '{}' was deleted or renamed in the current version"
45+
"Deleted or renamed method '{}.{}'"
4646
REMOVED_OR_RENAMED_MODULE_LEVEL_FUNCTION_MSG = \
47-
"The publicly exposed function '{}' was deleted or renamed in the current version"
47+
"Deleted or renamed function '{}'"
4848
REMOVED_OR_RENAMED_POSITIONAL_PARAM_OF_METHOD_MSG = \
49-
"The '{}' method '{}' had its parameter '{}' of kind '{}' deleted or renamed in the current version"
49+
"'{}.{}' method deleted or renamed its parameter '{}' of kind '{}'"
5050
REMOVED_OR_RENAMED_POSITIONAL_PARAM_OF_FUNCTION_MSG = \
51-
"The function '{}' had its parameter '{}' of kind '{}' deleted or renamed in the current version"
51+
"'{}' function deleted or renamed its parameter '{}' of kind '{}'"
5252
ADDED_POSITIONAL_PARAM_TO_METHOD_MSG = \
53-
"The '{}' method '{}' had a '{}' parameter '{}' inserted in the current version"
53+
"'{}.{}' method inserted a '{}' parameter '{}'"
5454
ADDED_POSITIONAL_PARAM_TO_FUNCTION_MSG = \
55-
"The function '{}' had a '{}' parameter '{}' inserted in the current version"
55+
"'{}' function inserted a '{}' parameter '{}'"
5656
REMOVED_OR_RENAMED_INSTANCE_ATTRIBUTE_FROM_CLIENT_MSG = \
57-
"The client '{}' had its instance variable '{}' deleted or renamed in the current version"
57+
"'{}' deleted or renamed client instance variable '{}'"
5858
REMOVED_OR_RENAMED_INSTANCE_ATTRIBUTE_FROM_MODEL_MSG = \
59-
"The model or publicly exposed class '{}' had its instance variable '{}' deleted or renamed " \
60-
"in the current version"
59+
"'{}' model deleted or renamed its instance variable '{}'"
6160
REMOVED_OR_RENAMED_ENUM_VALUE_MSG = \
62-
"The '{}' enum had its value '{}' deleted or renamed in the current version"
61+
"Deleted or renamed enum value '{}.{}'"
6362
CHANGED_PARAMETER_DEFAULT_VALUE_MSG = \
64-
"The class '{}' method '{}' had its parameter '{}' default value changed from '{}' to '{}'"
63+
"'{}.{}' method parameter '{}' changed default value from '{}' to '{}'"
6564
CHANGED_PARAMETER_DEFAULT_VALUE_OF_FUNCTION_MSG = \
66-
"The publicly exposed function '{}' had its parameter '{}' default value changed from '{}' to '{}'"
65+
"'{}' function parameter '{}' changed default value from '{}' to '{}'"
6766
REMOVED_PARAMETER_DEFAULT_VALUE_MSG = \
68-
"The class '{}' method '{}' had default value '{}' removed from its parameter '{}' in " \
69-
"the current version"
67+
"'{}.{}' removed default method value '{}' from its parameter '{}'"
7068
REMOVED_PARAMETER_DEFAULT_VALUE_OF_FUNCTION_MSG = \
71-
"The publicly exposed function '{}' had default value '{}' removed from its parameter '{}' in " \
72-
"the current version"
69+
"'{}' function removed default value '{}' from its parameter '{}'"
7370
CHANGED_PARAMETER_ORDERING_MSG = \
74-
"The class '{}' method '{}' had its parameters re-ordered from '{}' to '{}' in the current version"
71+
"'{}.{}' method re-ordered its parameters from '{}' to '{}'"
7572
CHANGED_PARAMETER_ORDERING_OF_FUNCTION_MSG = \
76-
"The publicly exposed function '{}' had its parameters re-ordered from '{}' to '{}' in " \
77-
"the current version"
73+
"'{}' function re-ordered its parameters from '{}' to '{}'"
7874
CHANGED_PARAMETER_KIND_MSG = \
79-
"The class '{}' method '{}' had its parameter '{}' changed from '{}' to '{}' in the current version"
75+
"'{}.{}' method changed its parameter '{}' from '{}' to '{}'"
8076
CHANGED_PARAMETER_KIND_OF_FUNCTION_MSG = \
81-
"The function '{}' had its parameter '{}' changed from '{}' to '{}' in the current version"
77+
"'{}' function changed its parameter '{}' from '{}' to '{}'"
8278
CHANGED_CLASS_FUNCTION_KIND_MSG = \
83-
"The class '{}' method '{}' changed from '{}' to '{}' in the current version."
79+
"'{}.{}' method changed from '{}' to '{}'"
8480
CHANGED_FUNCTION_KIND_MSG = \
85-
"The function '{}' changed from '{}' to '{}' in the current version."
81+
"Changed function '{}' from '{}' to '{}'"
8682
REMOVED_OR_RENAMED_MODULE_MSG = \
87-
"The '{}' module was deleted or renamed in the current version"
83+
"Deleted or renamed module '{}'"
8884
REMOVED_CLASS_FUNCTION_KWARGS_MSG = \
89-
"The class '{}' method '{}' changed from accepting keyword arguments to not accepting them in " \
90-
"the current version"
85+
"'{}.{}' method changed from accepting keyword arguments to not accepting them"
9186
REMOVED_FUNCTION_KWARGS_MSG = \
92-
"The function '{}' changed from accepting keyword arguments to not accepting them in " \
93-
"the current version"
87+
"'{}' function changed from accepting keyword arguments to not accepting them"
9488
REMOVED_OR_RENAMED_OPERATION_GROUP_MSG = \
95-
"The '{}' client had operation group '{}' deleted or renamed in the current version"
89+
"Deleted or renamed client operation group '{}.{}'"
9690

9791
def __init__(self, stable: Dict, current: Dict, diff: Dict, package_name: str, **kwargs: Any) -> None:
9892
self.stable = stable

scripts/breaking_changes_checker/changelog_tracker.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ class ChangeType(str, Enum):
2323

2424
class ChangelogTracker(BreakingChangesTracker):
2525
ADDED_CLIENT_MSG = \
26-
"The client '{}' was added in the current version"
26+
"Added client '{}'"
2727
ADDED_CLIENT_METHOD_MSG = \
28-
"The '{}' client method '{}' was added in the current version"
28+
"Client '{}' added method '{}'"
2929
ADDED_CLASS_MSG = \
30-
"The model or publicly exposed class '{}' was added in the current version"
30+
"Added model '{}'"
3131
ADDED_CLASS_METHOD_MSG = \
32-
"The '{}' method '{}' was added in the current version"
32+
"Model '{}' added method '{}'"
3333
ADDED_CLASS_METHOD_PARAMETER_MSG = \
34-
"The model or publicly exposed class '{}' had property '{}' added in the {} method in the current version"
34+
"Model '{}' added parameter '{}' in the '{}' method"
3535
ADDED_FUNCTION_PARAMETER_MSG = \
36-
"The function '{}' had parameter '{}' added in the current version"
36+
"Function '{}' added parameter '{}'"
3737
ADDED_CLASS_PROPERTY_MSG = \
38-
"The model or publicly exposed class '{}' had property '{}' added in the current version"
38+
"Model '{}' added property '{}'"
3939
ADDED_OPERATION_GROUP_MSG = \
40-
"The '{}' client had operation group '{}' added in the current version"
40+
"Client '{}' added operation group '{}'"
4141

4242

4343
def __init__(self, stable: Dict, current: Dict, diff: Dict, package_name: str, **kwargs: Any) -> None:

scripts/breaking_changes_checker/tests/test_breaking_changes.py

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,25 @@ def format_breaking_changes(breaking_changes):
2424
return formatted
2525

2626
EXPECTED = [
27-
"(RemovedOrRenamedInstanceAttribute): The model or publicly exposed class 'Metrics' had its instance variable 'retention_policy' deleted or renamed in the current version",
28-
"(RemovedOrRenamedInstanceAttribute): The client 'QueueClient' had its instance variable 'queue_name' deleted or renamed in the current version",
29-
"(ChangedParameterKind): The class 'QueueClient' method 'from_queue_url' had its parameter 'credential' changed from 'positional_or_keyword' to 'keyword_only' in the current version",
30-
"(AddedPositionalParam): The 'QueueClient' method 'get_queue_access_policy' had a 'positional_or_keyword' parameter 'queue_name' inserted in the current version",
31-
"(RemovedOrRenamedPositionalParam): The 'QueueClient' method 'set_queue_access_policy' had its parameter 'signed_identifiers' of kind 'positional_or_keyword' deleted or renamed in the current version",
32-
"(ChangedParameterDefaultValue): The class 'QueueClient' method 'set_queue_metadata' had its parameter 'metadata' default value changed from 'None' to ''",
33-
"(RemovedOrRenamedClassMethod): The 'QueueSasPermissions' method 'from_string' was deleted or renamed in the current version",
34-
"(RemovedFunctionKwargs): The class 'QueueServiceClient' method 'set_service_properties' changed from accepting keyword arguments to not accepting them in the current version",
35-
"(RemovedOrRenamedClientMethod): The 'QueueServiceClient' client method 'get_service_properties' was deleted or renamed in the current version",
36-
"(RemovedOrRenamedEnumValue): The 'StorageErrorCode' enum had its value 'queue_not_found' deleted or renamed in the current version",
37-
"(RemovedOrRenamedClass): The model or publicly exposed class 'QueueMessage' was deleted or renamed in the current version",
38-
"(ChangedParameterDefaultValue): The publicly exposed function 'generate_queue_sas' had its parameter 'permission' default value changed from 'None' to ''",
39-
"(ChangedParameterKind): The function 'generate_queue_sas' had its parameter 'ip' changed from 'positional_or_keyword' to 'keyword_only' in the current version",
40-
"(AddedPositionalParam): The function 'generate_queue_sas' had a 'positional_or_keyword' parameter 'conn_str' inserted in the current version",
41-
"(RemovedOrRenamedPositionalParam): The function 'generate_queue_sas' had its parameter 'account_name' of kind 'positional_or_keyword' deleted or renamed in the current version",
42-
"(RemovedOrRenamedModuleLevelFunction): The publicly exposed function 'generate_account_sas' was deleted or renamed in the current version",
43-
"(ChangedParameterKind): The class 'QueueClient' method 'from_queue_url' had its parameter 'credential' changed from 'positional_or_keyword' to 'keyword_only' in the current version",
44-
"(RemovedParameterDefaultValue): The class 'QueueClient' method 'update_message' had default value 'None' removed from its parameter 'pop_receipt' in the current version",
45-
"(ChangedFunctionKind): The class 'QueueServiceClient' method 'get_service_stats' changed from 'asynchronous' to 'synchronous' in the current version.",
46-
"(ChangedParameterOrdering): The class 'QueueClient' method 'from_connection_string' had its parameters re-ordered from '['conn_str', 'queue_name', 'credential', 'kwargs']' to '['queue_name', 'conn_str', 'credential', 'kwargs']' in the current version",
47-
"(ChangedParameterOrdering): The class 'QueueClient' method 'from_connection_string' had its parameters re-ordered from '['conn_str', 'queue_name', 'credential', 'kwargs']' to '['queue_name', 'conn_str', 'credential', 'kwargs']' in the current version",
27+
"(RemovedOrRenamedInstanceAttribute): 'Metrics' model deleted or renamed its instance variable 'retention_policy'",
28+
"(RemovedOrRenamedInstanceAttribute): 'QueueClient' deleted or renamed client instance variable 'queue_name'",
29+
"(ChangedParameterKind): 'QueueClient.from_queue_url' method changed its parameter 'credential' from 'positional_or_keyword' to 'keyword_only'",
30+
"(AddedPositionalParam): 'QueueClient.get_queue_access_policy' method inserted a 'positional_or_keyword' parameter 'queue_name'",
31+
"(RemovedOrRenamedPositionalParam): 'QueueClient.set_queue_access_policy' method deleted or renamed its parameter 'signed_identifiers' of kind 'positional_or_keyword'",
32+
"(ChangedParameterDefaultValue): 'QueueClient.set_queue_metadata' method parameter 'metadata' changed default value from 'None' to ''",
33+
"(RemovedOrRenamedClassMethod): Deleted or renamed method 'QueueSasPermissions.from_string'",
34+
"(RemovedFunctionKwargs): 'QueueServiceClient.set_service_properties' method changed from accepting keyword arguments to not accepting them",
35+
"(RemovedOrRenamedClientMethod): Deleted or renamed client method 'QueueServiceClient.get_service_properties'",
36+
"(RemovedOrRenamedEnumValue): Deleted or renamed enum value 'StorageErrorCode.queue_not_found'",
37+
"(RemovedOrRenamedClass): Deleted or renamed model 'QueueMessage'",
38+
"(ChangedParameterDefaultValue): 'generate_queue_sas' function parameter 'permission' changed default value from 'None' to ''",
39+
"(ChangedParameterKind): 'generate_queue_sas' function changed its parameter 'ip' from 'positional_or_keyword' to 'keyword_only'",
40+
"(AddedPositionalParam): 'generate_queue_sas' function inserted a 'positional_or_keyword' parameter 'conn_str'",
41+
"(RemovedOrRenamedPositionalParam): 'generate_queue_sas' function deleted or renamed its parameter 'account_name' of kind 'positional_or_keyword'",
42+
"(RemovedOrRenamedModuleLevelFunction): Deleted or renamed function 'generate_account_sas'",
43+
"(RemovedParameterDefaultValue): 'QueueClient.update_message' removed default method value 'None' from its parameter 'pop_receipt'",
44+
"(ChangedFunctionKind): 'QueueServiceClient.get_service_stats' method changed from 'asynchronous' to 'synchronous'",
45+
"(ChangedParameterOrdering): 'QueueClient.from_connection_string' method re-ordered its parameters from '['conn_str', 'queue_name', 'credential', 'kwargs']' to '['queue_name', 'conn_str', 'credential', 'kwargs']'",
4846
]
4947

5048

@@ -74,8 +72,7 @@ def test_ignore_checks():
7472

7573
ignore = {
7674
"azure-storage-queue": [
77-
("ChangedParameterOrdering", "azure.storage.queue.aio", "QueueClient", "from_connection_string"),
78-
("ChangedParameterOrdering", "azure.storage.queue", "QueueClient", "from_connection_string"),
75+
("ChangedParameterOrdering", "*", "QueueClient", "from_connection_string"),
7976
]
8077
}
8178

@@ -84,8 +81,8 @@ def test_ignore_checks():
8481

8582
changes = bc.report_changes()
8683

87-
expected_msg = format_breaking_changes(EXPECTED[:-2])
88-
assert len(bc.breaking_changes)+2 == len(EXPECTED)
84+
expected_msg = format_breaking_changes(EXPECTED[:-1])
85+
assert len(bc.breaking_changes)+1 == len(EXPECTED)
8986
assert changes == expected_msg
9087

9188

@@ -108,8 +105,8 @@ def test_ignore_with_wildcard_checks():
108105

109106
changes = bc.report_changes()
110107

111-
expected_msg = format_breaking_changes(EXPECTED[:-3])
112-
assert len(bc.breaking_changes)+3 == len(EXPECTED)
108+
expected_msg = format_breaking_changes(EXPECTED[:-2])
109+
assert len(bc.breaking_changes)+2 == len(EXPECTED)
113110
assert changes == expected_msg
114111

115112

@@ -184,10 +181,10 @@ def test_replace_all_params():
184181
}
185182

186183
EXPECTED = [
187-
"(RemovedOrRenamedPositionalParam): The 'class_name' method 'one' had its parameter 'testing' of kind 'positional_or_keyword' deleted or renamed in the current version",
188-
"(RemovedOrRenamedPositionalParam): The 'class_name' method 'two' had its parameter 'testing2' of kind 'positional_or_keyword' deleted or renamed in the current version",
189-
"(RemovedOrRenamedPositionalParam): The function 'my_function_name' had its parameter 'testing' of kind 'positional_or_keyword' deleted or renamed in the current version",
190-
"(RemovedOrRenamedPositionalParam): The function 'my_function_name' had its parameter 'testing2' of kind 'positional_or_keyword' deleted or renamed in the current version"
184+
"(RemovedOrRenamedPositionalParam): 'class_name.one' method deleted or renamed its parameter 'testing' of kind 'positional_or_keyword'",
185+
"(RemovedOrRenamedPositionalParam): 'class_name.two' method deleted or renamed its parameter 'testing2' of kind 'positional_or_keyword'",
186+
"(RemovedOrRenamedPositionalParam): 'my_function_name' function deleted or renamed its parameter 'testing' of kind 'positional_or_keyword'",
187+
"(RemovedOrRenamedPositionalParam): 'my_function_name' function deleted or renamed its parameter 'testing2' of kind 'positional_or_keyword'"
191188
]
192189

193190
diff = jsondiff.diff(stable, current)
@@ -272,10 +269,10 @@ def test_replace_all_functions():
272269
}
273270

274271
EXPECTED = [
275-
"(RemovedOrRenamedClassMethod): The 'class_name' method 'one' was deleted or renamed in the current version",
276-
"(RemovedOrRenamedClassMethod): The 'class_name' method 'two' was deleted or renamed in the current version",
277-
"(RemovedOrRenamedModuleLevelFunction): The publicly exposed function 'my_function_name' was deleted or renamed in the current version",
278-
"(RemovedOrRenamedModuleLevelFunction): The publicly exposed function 'my_function_name2' was deleted or renamed in the current version"
272+
"(RemovedOrRenamedClassMethod): Deleted or renamed method 'class_name.one'",
273+
"(RemovedOrRenamedClassMethod): Deleted or renamed method 'class_name.two'",
274+
"(RemovedOrRenamedModuleLevelFunction): Deleted or renamed function 'my_function_name'",
275+
"(RemovedOrRenamedModuleLevelFunction): Deleted or renamed function 'my_function_name2'"
279276
]
280277

281278
diff = jsondiff.diff(stable, current)
@@ -348,8 +345,8 @@ def test_replace_all_classes():
348345
}
349346

350347
EXPECTED = [
351-
"(RemovedOrRenamedClass): The model or publicly exposed class 'class_name' was deleted or renamed in the current version",
352-
"(RemovedOrRenamedClass): The model or publicly exposed class 'class_name2' was deleted or renamed in the current version"
348+
"(RemovedOrRenamedClass): Deleted or renamed model 'class_name'",
349+
"(RemovedOrRenamedClass): Deleted or renamed model 'class_name2'"
353350
]
354351

355352
diff = jsondiff.diff(stable, current)
@@ -376,8 +373,7 @@ def test_replace_all_modules():
376373
}
377374

378375
EXPECTED = [
379-
"(RemovedOrRenamedModule): The 'azure.ai.formrecognizer' module was deleted or renamed in the current version",
380-
"(RemovedOrRenamedModule): The 'azure.ai.formrecognizer.aio' module was deleted or renamed in the current version"
376+
"(RemovedOrRenamedModule): Deleted or renamed module 'azure.ai.formrecognizer'",
381377
]
382378

383379
diff = jsondiff.diff(stable, current)
@@ -434,7 +430,7 @@ def test_removed_operation_group():
434430
}
435431

436432
EXPECTED = [
437-
"(RemovedOrRenamedOperationGroup): The 'ContosoClient' client had operation group 'foo' deleted or renamed in the current version"
433+
"(RemovedOrRenamedOperationGroup): Deleted or renamed client operation group 'ContosoClient.foo'"
438434
]
439435

440436
diff = jsondiff.diff(stable, current)
@@ -459,7 +455,7 @@ def test_async_breaking_changes_cleanup():
459455
bct = BreakingChangesTracker({}, {}, {}, "azure-contoso")
460456
bct.breaking_changes = breaking_changes
461457

462-
bct.run_async_breaking_cleanup()
458+
bct.run_async_cleanup(bct.breaking_changes)
463459

464460
assert len(bct.breaking_changes) == 2
465461
assert bct.breaking_changes[0] == ("Message", "RemovedOrRenamedClassMethod", "azure.contoso.operations", "Foo", "foo")

scripts/breaking_changes_checker/tests/test_changelog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def test_async_features_added_cleanup():
452452
ct = ChangelogTracker({}, {}, {}, "azure-contoso")
453453
ct.features_added = features_added
454454

455-
ct.run_async_changelog_cleanup()
455+
ct.run_async_cleanup(ct.features_added)
456456

457457
assert len(ct.features_added) == 2
458458
assert ct.features_added[0] == ("Message", "AddedClient", "azure.contoso", "FooClient", "foo")

0 commit comments

Comments
 (0)