Skip to content

DOC: Correct error message in AbstractMethodError for methodtype argument #61827

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Maaz-319
Copy link

Fixing an error message in the AbstractMethodError class found in pandas/errors/init.py.
Currently:
raise ValueError(
f"methodtype must be one of {methodtype}, got {types} instead."
)
Here, {methodtype} and {types} are swapped.
This means if you called this error with methodtype="foo", the message would read:
methodtype must be one of foo, got {'method', 'classmethod', 'staticmethod', 'property'} instead.

That’s confusing, because the set of valid types should be listed after “must be one of”, and the invalid value you passed should be listed after “got”.

Corrected:

raise ValueError(
f"methodtype must be one of {types}, got {methodtype} instead."
)
Now, if you called this error with methodtype="foo", the message would read:
methodtype must be one of {'method', 'classmethod', 'staticmethod', 'property'}, got foo instead.

This is clearer and follows standard error message conventions.

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 this pull request may close these issues.

1 participant