terrencepreilly / darglint

A python documentation linter which checks that the docstring description matches the definition.
MIT License
483 stars 41 forks source link

Optional arg is not seen, if we have mypy info (eg, `def fun(x: bool = True)`) #197

Open bcm-at-zama opened 2 years ago

bcm-at-zama commented 2 years ago

Hello, I've an issue with

def fun(x: bool = True):
    """This is my docstring.

    Args:
        x (bool, optional): some condition

    """
    if x:
        print("A")
    print("B")

which gives a.py:fun:5: DAR103: ~x: expected bool but was bool, optional.

Remark that

def fun(x=True):
    """This is my docstring.

    Args:
        x (optional): some condition

    """
    if x:
        print("A")
    print("B")

works fine, ie the problem seems to come from the : bool mypy hint.

Extra info:

1.8.1
% sw_vers
ProductName:    macOS
ProductVersion: 11.6
BuildVersion:   20G165
bcm-at-zama commented 2 years ago

Thanks for the tool by the way, it is very nice to build great doc for the user!