Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

False positive D417 fixed by adding unrelated section #527

Closed
dargueta opened this issue Mar 9, 2021 · 2 comments
Closed

False positive D417 fixed by adding unrelated section #527

dargueta opened this issue Mar 9, 2021 · 2 comments

Comments

@dargueta
Copy link

dargueta commented Mar 9, 2021

Given a file containing the following:

def validate_lambda(task_id: str, lambda_root: str, entry_point_path: str) -> None:
    """Ensure the directory and source code paths for a Python Lambda are correct.

    Arguments:
        task_id (str):
            The ID of the task being examined. Only used in error messages.
        lambda_root (str):
            The path to the root directory where the Lambda's source code, requirements
            files, Dockerfile, etc. are defined.
        entry_point_path (str):
            A path relative to ``lambda_root`` that points to the Python file containing
            the entry point of this lambda.
    """

run:

python3 -m pydocstyle --convention=google test_file.py

output:

test.py:1 at module level:
        D100: Missing docstring in public module
test.py:2 in public function `validate_lambda`:
        D417: Missing argument descriptions in the docstring (argument(s) entry_point_path, lambda_root, task_id are missing descriptions in 'validate_lambda' docstring)

Note that it's convinced there are no argument descriptions. Now let's tweak the docstring by adding a "Returns" section:

def validate_lambda(task_id: str, lambda_root: str, entry_point_path: str) -> None:
    """Ensure the directory and source code paths for a Python Lambda are correct.

    Arguments:
        task_id (str):
            The ID of the task being examined. Only used in error messages.
        lambda_root (str):
            The path to the root directory where the Lambda's source code, requirements
            files, Dockerfile, etc. are defined.
        entry_point_path (str):
            A path relative to ``lambda_root`` that points to the Python file containing
            the entry point of this lambda.

    Returns:
        Nothing.
    """

The error is now gone, even though we didn't change anything:

test.py:1 at module level:
        D100: Missing docstring in public module

Oddly, putting Returns: Nothing on a single line doesn't fix the issue and gives the same error message. Adding a different directive like Raises: also works.

Environment:

  • pydocstyle 5.1.1 and 6.0.0
  • CPython 3.8.6
  • OS: MacOS 11.2.3
@HacKanCuBa
Copy link

HacKanCuBa commented May 5, 2021

I can confirm this, it's happening to me with Keyword Args for __init__ methods (not in other public methods!) whereas if I leave the argument under Args it just works.
The workaround described above works fine.

Environment:

pydocstyle: 6.0.0
CPython 3.9.4
OS: Linux 5.10.0-5-amd64 #1 SMP Debian 5.10.24-1 (2021-03-19) x86_64 GNU/Linux

@sambhav
Copy link
Member

sambhav commented May 17, 2021

Related to/Duplicate of #514 and #482

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

No branches or pull requests

3 participants