"Missing 1 required positional argument" raised even though arg's were passed


In https://replit.com/@BillyHornets/Tracker#main.py what I did was make a discord bot which, is listening to a command and executes a function when someone types the command. However even though that function is given the right amount of arguments, a “Missing required positional” error is still raised. What is the reasoning for this?

what line does the error come from?

Oh sorry, I didn’t mention this. The full error message is as follows:

Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 24, in on_message
    name = str(Tracker.get_info(raw)["Name"])
TypeError: get_info() missing 1 required positional argument: 'Name'

Shouldn’t the get_info method be called on t and not on Tracker?

I’m not very knowledgeable about Python but calling it on the class would suggest to me it had to be a static method on the class and not an instance method.

1 Like

Wait no, your right. It should have been called on t an not tracker. This time it raised a different error. Lemme mess around with this error real quick.

Yup, That’s the fix. It turns out errors like these always due to stupid mistakes. My bad!

1 Like

Good to hear.

I’m also glad I’m not totally crazy and that some base knowledge of languages can transfer between languages as expected. My guess on what was wrong was just based on the fact that I assumed that when called as a static method you would not get access to self, so the argument list changed. And purely going by the error message you got that would make sense.

Anyway, happy coding.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.