fix: ensure current module is referenced correctly in __get_deprecation_class

This commit is contained in:
Anish 2026-03-17 15:15:55 +05:30
parent c1cb375379
commit 4a4a2957c2

View file

@ -79,11 +79,11 @@ class V17FrappeDeprecationWarning(PendingFrappeDeprecationWarning):
def __get_deprecation_class(graduation: str | None = None, class_name: str | None = None) -> type: def __get_deprecation_class(graduation: str | None = None, class_name: str | None = None) -> type:
current_module = sys.modules[__name__]
if graduation: if graduation:
# Scrub the graduation string to ensure it's a valid class name # Scrub the graduation string to ensure it's a valid class name
cleaned_graduation = re.sub(r"\W|^(?=\d)", "_", graduation.upper()) cleaned_graduation = re.sub(r"\W|^(?=\d)", "_", graduation.upper())
class_name = f"{cleaned_graduation}FrappeDeprecationWarning" class_name = f"{cleaned_graduation}FrappeDeprecationWarning"
current_module = sys.modules[__name__]
try: try:
return getattr(current_module, class_name) return getattr(current_module, class_name)
except AttributeError: except AttributeError: