Skip to content

missing-param-doc W9015 false positive for typing.Union #8628

Open
@xqgex

Description

@xqgex

Bug description

When the variable type is a union of Enum and string I get a missing parameter documentation error.

test.py

""" Description of the module. """

from enum import Enum
from typing import Union


class SomeEnum(Enum):
    """ Enum description. """
    MEMBER_1 = 'value 1'
    MEMBER_2 = 'value 2'


class SomeClass:
    """ Class description. """

    def __init__(self) -> None:
        self.name: str = 'lorem ipsum'

    def too_few_public_methods(self) -> str:
        """ Function description.

        :return: A description of the return value.
        :rtype: str
        """
        return self.name

    def test_function(self, name: Union[str, SomeEnum]) -> bool:
        """ Function description.

        :param Union[str, SomeEnum] name: The description of the input variable.
        :return: A description of the return value.
        :rtype: bool
        """
        return name == self.name

Configuration

No response

Command used

python3.10 -m pylint --load-plugins pylint.extensions.docparams --accept-no-param-doc false ./test.py

Pylint output

************* Module test.test
test.py:27:4: W9015: "name" missing in parameter documentation (missing-param-doc)

------------------------------------------------------------------
Your code has been rated at 9.17/10 (previous run: 9.17/10, +0.00)

Expected behavior

-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 9.17/10, +0.83)

Pylint version

pylint 2.15.7
astroid 2.12.13
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]

OS / Environment

Ubuntu 22.04 LTS

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codetyping

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions