You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'll probably do something like the following in defaults.py
# mymodule.pyimportwarnings# ✅ Non-deprecated exportNEW_CONSTANT="new value"# ⚠️ Deprecated export (will warn on access)_OLD_CONSTANT="old value"def__getattr__(name):
ifname=="OLD_CONSTANT":
warnings.warn(
"OLD_CONSTANT is deprecated and will be removed in a future version. Use NEW_CONSTANT instead.",
category=DeprecationWarning,
stacklevel=2,
)
return_OLD_CONSTANTraiseAttributeError(f"module {__name__} has no attribute {name}")
I'll probably do something like the following in defaults.py
mymodule.py
import warnings
✅ Non-deprecated export
NEW_CONSTANT = "new value"
⚠️ Deprecated export (will warn on access)
_OLD_CONSTANT = "old value"
def getattr(name):
if name == "OLD_CONSTANT":
warnings.warn(
"OLD_CONSTANT is deprecated and will be removed in a future version. Use NEW_CONSTANT instead.",
category=DeprecationWarning,
stacklevel=2,
)
return _OLD_CONSTANT
raise AttributeError(f"module {name} has no attribute {name}")
Yep, PEP562 is definitely something we should use 🙂
Activity
bearomorphism commentedon May 22, 2025
Relevant commit: 94c02b3
bearomorphism commentedon May 22, 2025
I'll probably do something like the following in
defaults.py
fix(defaults): add non-capitalized default constants back and depreca…
Lee-W commentedon May 23, 2025
Yep, PEP562 is definitely something we should use 🙂
fix(defaults): add non-capitalized default constants back and depreca…
fix(defaults): add non-capitalized default constants back and depreca…
fix(defaults): add non-capitalized default constants back and depreca…
fix(defaults): add non-capitalized default constants back and depreca…
fix(defaults): add non-capitalized default constants back and depreca…
:meta private:
to the doc string #15024 remaining items