Improve Deprecation Warning for __slots__ (#2574)

* add stacklevel to `set_new_attribute_deprecated`

* detail warning message and change stacklevel
This commit is contained in:
Harshil 2021-06-29 21:40:08 +05:30 committed by GitHub
parent 9aec8deec6
commit fce2993d21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,6 +40,8 @@ def set_new_attribute_deprecated(self: object, key: str, value: object) -> None:
new = len(self.__dict__)
if new > org:
warnings.warn(
"Setting custom attributes on objects of the PTB library is deprecated.",
f"Setting custom attributes such as {key!r} on objects such as "
f"{self.__class__.__name__!r} of the PTB library is deprecated.",
TelegramDeprecationWarning,
stacklevel=3,
)