Skip to content

Commit daeeb7d

Browse files
authored
Add possibility to ignore common deprecated message (#20444)
There are some cases where deprecation of a commonly used dependency causes deprecation message in multiple dependencies. This happened in December 2021 with distutils deprecation. The disutil deprecation started to appear as new versions of multiple packages were released. This change adds such "common" deprecation messages that should be filtered out independently where they were generated.
1 parent c6dbb3f commit daeeb7d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

dev/provider_packages/prepare_provider_packages.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,10 @@ def summarise_total_vs_bad_and_warnings(total: int, bad: int, warns: List[warnin
20492049
console.print("[yellow]There are two cases that are legitimate deprecation warnings though:[/]")
20502050
console.print("[yellow] 1) when you deprecate whole module or class and replace it in provider[/]")
20512051
console.print("[yellow] 2) when 3rd-party module generates Deprecation and you cannot upgrade it[/]")
2052+
console.print(
2053+
"[yellow] 3) when many 3rd-party module generates same Deprecation warning that "
2054+
"comes from another common library[/]"
2055+
)
20522056
console.print()
20532057
console.print(
20542058
"[yellow]In case 1), add the deprecation message to "
@@ -2058,6 +2062,10 @@ def summarise_total_vs_bad_and_warnings(total: int, bad: int, warns: List[warnin
20582062
"[yellow]In case 2), add the deprecation message together with module it generates to "
20592063
"the KNOWN_DEPRECATED_MESSAGES in prepare_provider_packages.py[/]"
20602064
)
2065+
console.print(
2066+
"[yellow]In case 3), add the deprecation message to "
2067+
"the KNOWN_COMMON_DEPRECATED_MESSAGES in prepare_provider_packages.py[/]"
2068+
)
20612069
console.print()
20622070
raise_error = True
20632071
else:
@@ -2102,7 +2110,6 @@ def summarise_total_vs_bad_and_warnings(total: int, bad: int, warns: List[warnin
21022110
("dns.hash module will be removed in future versions. Please use hashlib instead.", "dns"),
21032111
("PKCS#7 support in pyOpenSSL is deprecated. You should use the APIs in cryptography.", "eventlet"),
21042112
("PKCS#12 support in pyOpenSSL is deprecated. You should use the APIs in cryptography.", "eventlet"),
2105-
("distutils Version classes are deprecated. Use packaging.version instead.", "eventlet"),
21062113
(
21072114
"the imp module is deprecated in favour of importlib; see the module's documentation"
21082115
" for alternative uses",
@@ -2116,7 +2123,10 @@ def summarise_total_vs_bad_and_warnings(total: int, bad: int, warns: List[warnin
21162123
),
21172124
("SelectableGroups dict interface is deprecated. Use select.", "kombu"),
21182125
("The module cloudant is now deprecated. The replacement is ibmcloudant.", "cloudant"),
2119-
("distutils Version classes are deprecated. Use packaging.version instead.", "dask"),
2126+
}
2127+
2128+
KNOWN_COMMON_DEPRECATED_MESSAGES: Set[str] = {
2129+
"distutils Version classes are deprecated. Use packaging.version instead."
21202130
}
21212131

21222132
# The set of warning messages generated by direct importing of some deprecated modules. We should only
@@ -2184,6 +2194,14 @@ def filter_direct_importlib_warning(warn: warnings.WarningMessage) -> bool:
21842194
return True
21852195

21862196

2197+
def filter_known_common_deprecated_messages(warn: warnings.WarningMessage) -> bool:
2198+
msg_string = str(warn.message).replace("\n", " ")
2199+
for m in KNOWN_COMMON_DEPRECATED_MESSAGES:
2200+
if msg_string == m:
2201+
return False
2202+
return True
2203+
2204+
21872205
@cli.command()
21882206
def verify_provider_classes():
21892207
"""Verifies names for all provider classes."""
@@ -2205,6 +2223,7 @@ def verify_provider_classes():
22052223
bad += inc_bad
22062224
warns = list(filter(filter_known_warnings, warns))
22072225
warns = list(filter(filter_direct_importlib_warning, warns))
2226+
warns = list(filter(filter_known_common_deprecated_messages, warns))
22082227
if not summarise_total_vs_bad_and_warnings(total, bad, warns):
22092228
sys.exit(1)
22102229

0 commit comments

Comments
 (0)