Skip to content
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

[Type Hinting] _log function is not properly annotated #4010

Closed
DavidEGx opened this issue Dec 14, 2023 · 1 comment · Fixed by #4151
Closed

[Type Hinting] _log function is not properly annotated #4010

DavidEGx opened this issue Dec 14, 2023 · 1 comment · Fixed by #4151
Assignees
Labels
type hinting Not bug. Not Docs. But both.

Comments

@DavidEGx
Copy link

Steps to Reproduce

  1. Create a test.py like:
import asyncio
import telegram

bot = telegram.Bot(token="some-token")
async def send_msg():
    await bot.send_message(chat_id="channel-id", text="Hello World")  # Argument missing for parameter "self"

asyncio.run(send_msg())
  1. Run
pyright test.py

You'll see:

test.py:6:11 - error: Argument missing for parameter "self" (reportGeneralTypeIssues)

Fix is described in pyright discussion, see microsoft/pyright#6669 (comment)

Expected behaviour

Code is properly annotated so pyright doesn't throw any error.

Actual behaviour

Pyright complains Argument missing for parameter "self"

Operating System

Ubuntu 23.10

Version of Python, python-telegram-bot & dependencies

python-telegram-bot 20.7
Bot API 6.9
Python 3.11.6 (main, Oct  8 2023, 05:06:43) [GCC 13.2.0]

Relevant log output

No response

Additional Context

No response

@Poolitzer Poolitzer self-assigned this Dec 14, 2023
@Bibo-Joshi
Copy link
Member

Bibo-Joshi commented Dec 14, 2023

Thanks for reaching out. This is in fact not the first time we had issues with the typing for this decorator, as it came up in #2677 before, which was adressed in #2686. I strongly suggest that we manually check compatability of a new fix with VSCode and PyCharm before merging.

It would also be good to use this chance to fix & improve our type completeness check as we discovered through this issue that it apparently fails silently.

It would be good to see if this check can automatically detect this shortcoming with a newer version of pyright. If it does not, we should reach out to pyright and ask for clarification.

Edit: The failing check is working again (see #4035) but does not report the issue.

@Bibo-Joshi Bibo-Joshi added type hinting Not bug. Not Docs. But both. and removed bug 🐛 labels Dec 14, 2023
@Bibo-Joshi Bibo-Joshi changed the title [BUG] _log function is not properly annotated [Type Hinting] _log function is not properly annotated Dec 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type hinting Not bug. Not Docs. But both.
Projects
None yet
3 participants