MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / warn

Function warn

src/telegram/_utils/warnings.py:34–56  ·  view source on GitHub ↗

Helper function used as a shortcut for warning with default values. .. versionadded:: 20.0 Args: message (:obj:`str` | :obj:`PTBUserWarning`): Specify the warnings message to pass to ``warnings.warn()``. .. versionchanged:: 21.2 Now als

(
    message: str | PTBUserWarning,
    category: type[Warning] = PTBUserWarning,
    stacklevel: int = 0,
)

Source from the content-addressed store, hash-verified

32
33
34def warn(
35 message: str | PTBUserWarning,
36 category: type[Warning] = PTBUserWarning,
37 stacklevel: int = 0,
38) -> None:
39 """
40 Helper function used as a shortcut for warning with default values.
41
42 .. versionadded:: 20.0
43
44 Args:
45 message (:obj:`str` | :obj:`PTBUserWarning`): Specify the warnings message to pass to
46 ``warnings.warn()``.
47
48 .. versionchanged:: 21.2
49 Now also accepts a :obj:`PTBUserWarning` instance.
50
51 category (:obj:`type[Warning]`, optional): Specify the Warning class to pass to
52 ``warnings.warn()``. Defaults to :class:`telegram.warnings.PTBUserWarning`.
53 stacklevel (:obj:`int`, optional): Specify the stacklevel to pass to ``warnings.warn()``.
54 Pass the same value as you'd pass directly to ``warnings.warn()``. Defaults to ``0``.
55 """
56 warnings.warn(message, category=category, stacklevel=stacklevel + 1)

Callers 15

effective_attachmentMethod · 0.90
effective_messageMethod · 0.90
__eq__Method · 0.90
de_jsonMethod · 0.90
__init__Method · 0.90
correct_option_idMethod · 0.90
_warnMethod · 0.90
send_pollMethod · 0.90
get_timedelta_valueFunction · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by 1

test_warnMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…