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

Endpoints without parameters throwing Exception #145

Closed
waner11 opened this issue Jul 27, 2024 · 5 comments · Fixed by #147
Closed

Endpoints without parameters throwing Exception #145

waner11 opened this issue Jul 27, 2024 · 5 comments · Fixed by #147

Comments

@waner11
Copy link

waner11 commented Jul 27, 2024

When attempting to call an endpoint without any parameters, such as 'teams' or 'awards', it throws an error. I've noticed in the code that it always expects parameters, even if the endpoint doesn't require any.

@BrayanMnz
Copy link
Contributor

Can you provide a code snippet to replicate this? @waner11

@toddrob99
Copy link
Owner

@BrayanMnz I think this is referring to calling statsapi.get() without only the endpoint parameter, e.g. statsapi.get("teams") rather than statsapi.get("teams", {}). The wrapper doesn't default the params to an empty dict, which I guess it could since not all endpoints require user-supplied parameters.

This is pedantic, but all endpoints do require at least one parameter (version)--the wrapper automatically adds it based on defaults in the endpoint definitions. The get function could still default to an empty dict.

@BrayanMnz
Copy link
Contributor

BrayanMnz commented Aug 14, 2024

Got it @toddrob99 , I will take a look on how this is built in the wrapper.
If you have any input that could be helpful will be great

@BrayanMnz
Copy link
Contributor

BrayanMnz commented Aug 14, 2024

is anyone don't understand what this issue means,
here is a snippet on how to replicate:

>>> import statsapi
>>> statsapi.get("teams")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: get() missing 1 required positional argument: 'params'

In the case of the teams endpoint, we need to pass an empty dict, in order for it to work.

>>> import statsapi
>>> statsapi.get("teams", {})

@toddrob99 toddrob99 mentioned this issue Oct 26, 2024
@toddrob99 toddrob99 linked a pull request Oct 26, 2024 that will close this issue
@waner11
Copy link
Author

waner11 commented Oct 29, 2024

I apologize for late reply, but yes is what @toddrob99 explained, when calling the statsapi.get() without any parameters other than the endpoint name, was throwing an exception. Thanks for taking care of this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants