mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add warning and log in TelegramObject.__setitem__
When Telegram adds a new field -> Aiogram will warn about this.
This commit is contained in:
parent
970c8b0b50
commit
d34e9c2faf
1 changed files with 6 additions and 0 deletions
|
|
@ -2,6 +2,8 @@ from __future__ import annotations
|
|||
|
||||
import io
|
||||
import typing
|
||||
import warnings
|
||||
from asyncio.log import logger
|
||||
from typing import TypeVar
|
||||
|
||||
from babel.support import LazyProxy
|
||||
|
|
@ -226,6 +228,10 @@ class TelegramObject(ContextInstanceMixin, metaclass=MetaTelegramObject):
|
|||
return self.props[key].set_value(self, value, self.conf.get('parent', None))
|
||||
self.values[key] = value
|
||||
|
||||
# Show and log a warning when Telegram silently adds new Fields
|
||||
warnings.warn(f"Field '{key}' doesn't exist in {self.__class__}")
|
||||
logger.warning(f"Field '{key}' doesn't exist in {self.__class__}")
|
||||
|
||||
def __contains__(self, item: str) -> bool:
|
||||
"""
|
||||
Check key contains in that object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue