Skip to content

Commit fce2993

Browse files
authored
Improve Deprecation Warning for __slots__ (python-telegram-bot#2574)
* add stacklevel to `set_new_attribute_deprecated` * detail warning message and change stacklevel
1 parent 9aec8de commit fce2993

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

telegram/utils/deprecate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def set_new_attribute_deprecated(self: object, key: str, value: object) -> None:
4040
new = len(self.__dict__)
4141
if new > org:
4242
warnings.warn(
43-
"Setting custom attributes on objects of the PTB library is deprecated.",
43+
f"Setting custom attributes such as {key!r} on objects such as "
44+
f"{self.__class__.__name__!r} of the PTB library is deprecated.",
4445
TelegramDeprecationWarning,
46+
stacklevel=3,
4547
)

0 commit comments

Comments
 (0)