False positive "Argument missing for parameter "self"? #6669
-
I see annoying error message "Argument missing for parameter "self". Is it a bug? 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()) $ .local/share/nvim/mason/bin/pyright --version
pyright 1.1.339
$ python -V
Python 3.10.12
$ pip freeze
python-telegram-bot==20.7 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This is a bug in the The correct way to type # Option 1: TypeVar bound to a Callable
T = TypeVar("T", bound=Callable[..., Any])
def _log(func: T) -> T: ...
# Option 2: Callable with a ParamSpec
P = ParamSpec("P")
R = TypeVar("R")
def _log(func: Callable[P, R]) -> Callable[P, R]: ... A third option is to remove all annotations for I recommend that you file a bug with the maintainers of this library. |
Beta Was this translation helpful? Give feedback.
-
file: pyproject.toml
Turn off this by set reportMissingParameterType = false |
Beta Was this translation helpful? Give feedback.
This is a bug in the
python-telegram-bot
library. Thesend_message
function is decorated with@_log
, and the_log
function is not properly annotated. If it were completely unannotated, pyright would infer its type correctly, but it is partially annotated, so pyright assumes that it shouldn't override the intent of the author.The correct way to type
_log
is to use aTypeVar
bound to aCallable
or aCallable
with aParamSpec
.…