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

Parameters not processed correctly for numpy style with incorrect underscoring #102

Open
d3nzil opened this issue Nov 16, 2023 · 1 comment

Comments

@d3nzil
Copy link

d3nzil commented Nov 16, 2023

In numpy style, when the underscoring count doesn't match the "Parameter", then pydoclint (version 0.3.8) reports error about arguments.

Example code:

def example(parameter: int) -> int:
    """This is a example function.

    Parameters
    ------
    parameter : int
        This is a example parameter.

    Returns
    -------
    int
        This is a example return value.
    """
    print(parameter)
    return parameter

Errors reported:

    1: DOC101: Function `example`: Docstring contains fewer arguments than in function signature. 
    1: DOC109: Function `example`: The option `--arg-type-hints-in-docstring` is `True` but there are no type hints in the docstring arg list
    1: DOC103: Function `example`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in 
the function signature but not in the docstring: [parameter: int].

No errors are reported when the underscores are fixed to match the "Parameters" line.

@jsh9
Copy link
Owner

jsh9 commented Nov 27, 2023

Hi @d3nzil , this happens because the docstring parser (https://github.com/jsh9/docstring_parser_fork) cannot properly parse a piece of docstring if it's not formatted correctly.

I can potentially make changes to the parser for it to be more "false tolerant", but there's a limit of how far this "tolerating" can go, because there can be infinitely many ways that a docstring can be incorrectly written.

So I feel that an easier "catch-all" way would be to update the error message or documentation to say "you are seeing this violation probably because your docstring isn't correctly formatted".

In fact, the message in DOC103 already kind of says that. I just need to refine it a bit.

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

No branches or pull requests

2 participants