Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
l-Il opened this issue Jan 2, 2025 · 3 comments Β· Fixed by #4634
Closed

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

l-Il opened this issue Jan 2, 2025 · 3 comments Β· Fixed by #4634

Comments

@l-Il
Copy link

l-Il commented Jan 2, 2025

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

@l-Il l-Il added the πŸ“‹ triage work status: triage label Jan 2, 2025
@Poolitzer
Copy link
Member

Poolitzer commented Jan 3, 2025

@l-Il While I don't think this should lead to an error, as a quick fix you can use pip install git+https://github.com/python-telegram-bot/python-telegram-bot@api_8.2 to upgrade to a compatible PTB "version".

Or just wait until we merge to master/release

@harshil21
Copy link
Member

Yeah, #4634 fixed this. You can upgrade to the branch and it should be fixed.

@Bibo-Joshi
Copy link
Member

Since #4634 addressed this already on master, I'll go ahead and close. A release including the bug fix will arrive today. Sorry for the inconvenience.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants