Compare commits

...

2 Commits

Author SHA1 Message Date
Erick Friis
c2234009cf x 2024-06-05 00:13:12 -04:00
Erick Friis
b4abdf1f9f core: throw error on invalid alternative_import in deprecated 2024-06-05 00:10:56 -04:00

View File

@@ -100,6 +100,18 @@ def deprecated(
pass
"""
if pending and removal:
raise ValueError("A pending deprecation cannot have a scheduled removal")
if alternative and alternative_import:
raise ValueError("Cannot specify both alternative and alternative_import")
if alternative_import and (
"." not in alternative_import or " " in alternative_import
):
raise ValueError(
"alternative_import must be a fully qualified module path, e.g. "
"`package.module.Class`"
)
def deprecate(
obj: T,
*,
@@ -337,12 +349,6 @@ def warn_deprecated(
since. Set to other Falsy values to not schedule a removal
date. Cannot be used together with pending.
"""
if pending and removal:
raise ValueError("A pending deprecation cannot have a scheduled removal")
if alternative and alternative_import:
raise ValueError("Cannot specify both alternative and alternative_import")
if alternative_import and "." not in alternative_import:
raise ValueError("alternative_import must be a fully qualified module path")
if not pending:
if not removal: