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

How to specify that parameter can equal the string 'integer'? #341

Closed
MarcoGorelli opened this issue Nov 26, 2021 · 2 comments · Fixed by #347
Closed

How to specify that parameter can equal the string 'integer'? #341

MarcoGorelli opened this issue Nov 26, 2021 · 2 comments · Fixed by #347

Comments

@MarcoGorelli
Copy link

Say I have the following:

def foo(bar: str) -> None:
    """
    Parameters
    ----------
    bar : {'integer', 'float'}
        Some description.
    """
    if bar not in {'integer', 'float'}:
        raise ValueError('bar is neither "integer" nor "float"')

The parameter bar is a str, and can only take on the values 'integer' and 'float'. However, if I run numpydoc on it, it reports:

$ python -m numpydoc t.foo --validate
t.foo:SS01:No summary found (a short summary in a single line should be present at the beginning of the docstring)
t.foo:ES01:No extended summary found
t.foo:PR06:Parameter "bar" type should use "int" instead of "integer"
t.foo:SA01:See Also section not found
t.foo:EX01:No examples section found

The first 2 and last 2 errors are expected, but the middle one (PR06) feels like a false positive.

Noticed when trying to validate pandas.to_numeric (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_numeric.html), which has a parameter downcast which can be equal to the string 'integer'

@rossbar
Copy link
Contributor

rossbar commented Jan 6, 2022

You're right, this is a bug in the numpydoc validation which fails to account for the fact that these values are part of a set of options.

@MarcoGorelli
Copy link
Author

Nice, thanks for fixing this!

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

Successfully merging a pull request may close this issue.

2 participants