From 5264cd7cdf422070642755da60d80cf5a4c8a727 Mon Sep 17 00:00:00 2001 From: Thomas Gibson Date: Thu, 29 Apr 2021 11:59:47 -0500 Subject: [PATCH] Add @alexfikl's patch for raising deprecation warnings --- grudge/dof_desc.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/grudge/dof_desc.py b/grudge/dof_desc.py index 13db8e80..fd3b9b60 100644 --- a/grudge/dof_desc.py +++ b/grudge/dof_desc.py @@ -306,9 +306,24 @@ def as_dofdesc(dd): # {{{ Deprecated tags -# FIXME: These are deprecated and will be removed -QTAG_NONE = DISCR_TAG_BASE -QTAG_MODAL = DISCR_TAG_MODAL +_deprecated_names = {"QTAG_NONE": "DISCR_TAG_BASE", + "QTAG_MODAL": "DISCR_TAG_MODAL"} + + +def __getattr__(name): + if name in _deprecated_names: + warn(f"{name} is deprecated and will be dropped " + f"in version 2022.x. Use {_deprecated_names[name]} instead.", + DeprecationWarning, stacklevel=2) + return globals()[f"{_deprecated_names[name]}"] + + raise AttributeError(f"module {__name__} has no attribute {name}") + +import sys + +if sys.version_info < (3, 7): + QTAG_NONE = DISCR_TAG_BASE + QTAG_MODAL = DISCR_TAG_MODAL # }}} -- GitLab