Skip to content

TypeError: Gift.__init__() got an unexpected keyword argument 'upgrade_star_count' #4637

@l-Il

Description

@l-Il

Steps to Reproduce

context.bot.get_available_gifts()

Expected behaviour

you get json from the server that is parsed with Gift class

Actual behaviour

TypeError: Gift.init() got an unexpected keyword argument 'upgrade_star_count'

Operating System

ubuntu

Version of Python, python-telegram-bot & dependencies

Requirement already satisfied: python-telegram-bot in  (21.9)
Requirement already satisfied: httpx~=0.27 in  (from python-telegram-bot) (0.27.2)
Requirement already satisfied: anyio in  (from httpx~=0.27->python-telegram-bot) (4.4.0)
Requirement already satisfied: certifi in  (from httpx~=0.27->python-telegram-bot) (2023.11.17)
Requirement already satisfied: httpcore==1.* in  (from httpx~=0.27->python-telegram-bot) (1.0.5)
Requirement already satisfied: idna in  (from httpx~=0.27->python-telegram-bot) (3.6)
Requirement already satisfied: sniffio in  (from httpx~=0.27->python-telegram-bot) (1.3.1)
Requirement already satisfied: h11<0.15,>=0.13 in  (from httpcore==1.*->httpx~=0.27->python-telegram-bot) (0.14.0)

Relevant log output

No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/home/USER/.local/lib/python3.12/site-packages/telegram/ext/_application.py", line 1325, in process_update
    await coroutine
  File "/home/USER/.local/lib/python3.12/site-packages/telegram/ext/_handlers/basehandler.py", line 158, in handle_update
    return await self.callback(update, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/bot.py", line 65, in gifts
    gifts = await context.bot.get_available_gifts()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/lib/python3.12/site-packages/telegram/ext/_extbot.py", line 4453, in get_available_gifts
    return await super().get_available_gifts(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/lib/python3.12/site-packages/telegram/_bot.py", line 9670, in get_available_gifts
    return Gifts.de_json(  # type: ignore[return-value]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/lib/python3.12/site-packages/telegram/_gifts.py", line 135, in de_json
    data["gifts"] = Gift.de_list(data.get("gifts"), bot)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/lib/python3.12/site-packages/telegram/_telegramobject.py", line 465, in de_list
    return tuple(obj for obj in (cls.de_json(d, bot) for d in data) if obj is not None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/lib/python3.12/site-packages/telegram/_telegramobject.py", line 465, in <genexpr>
    return tuple(obj for obj in (cls.de_json(d, bot) for d in data) if obj is not None)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/lib/python3.12/site-packages/telegram/_telegramobject.py", line 465, in <genexpr>
    return tuple(obj for obj in (cls.de_json(d, bot) for d in data) if obj is not None)
                                 ^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.local/lib/python3.12/site-packages/telegram/_gifts.py", line 93, in de_json
    return cls(**data)
           ^^^^^^^^^^^
TypeError: Gift.__init__() got an unexpected keyword argument 'upgrade_star_count'

Additional Context

after a recent update of the Telegram API, "get_available_gifts" was added to the Gift class, which is not in the library, so any requests with the get_available_gifts() method end with an error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions