Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Stray DAR003 issue when using sphinx type docstring #172

Open
agatti opened this issue Jul 22, 2021 · 3 comments
Open

Stray DAR003 issue when using sphinx type docstring #172

agatti opened this issue Jul 22, 2021 · 3 comments

Comments

@agatti
Copy link

agatti commented Jul 22, 2021

Similar to #117, on darglint 1.8.0 I am getting a DAR003 issue on a docstring that does not look like has anything strange going for it and I am wondering what I am doing wrong with that. The code fragment is as follows:

@pytest.fixture(scope="session")
def ssh_output_path() -> Path:
    """Return the common path for output files created from tests.

    :returns: the output directory.
    :raise FileNotFoundError: if the found path does not exist.
    :raise NotADirectoryError: if the found path is not a directory.
    """

    path = Path("testoutput") / "test"
    check_directory_path(path)
    return path

and I also checked that there isn't any other spurious whitespace lingering around:

Screenshot 2021-07-23 at 01 17 16

The darglint configuration is set to default except for the docstring style being sphinx and strictness being set to full.

Interestingly the error message occurs on the first :raise line, with the same description as #117, "Incorrect indentation: ~<":

   205:   1 DAR003 Incorrect indentation: ~< [flake8-darglint]
  """Return the common path for output files created from tests.

    :returns: the output directory.
    :raise FileNotFoundError: if the found path does not exist.
    :raise NotADirectoryError: if the found path is not a directory.
    """
  ^

Is there anything else I can try to see if this can be sorted out?

Thanks!

@webknjaz
Copy link

@agatti is it :raise: or :raises:? I think it should be the latter.

@sziem
Copy link

sziem commented Jan 2, 2022

Thanks @webknjaz ! I just ran into the exact same issue, after writing :raise: instead of :raises: and was about to add an "ignore" comment, before I read your comment.

The confusing thing for me is that there appears to be some inconsistency between my pycharm editor and darglint linting.

The raise keyword is highlighted by pycharm as if it were a valid keyword, but darglint complains about it
image

$ flake8 src/man_adt/evaluation_utils/entrypoints/flake8.py 
src/man_adt/evaluation_utils/entrypoints/flake8.py:5:1: DAR401 Missing exception(s) in Raises section: -r ValueError
src/man_adt/evaluation_utils/entrypoints/flake8.py:8:1: DAR003 Incorrect indentation: ~<

I'm not an expert on docstrings, so I am not really sure, whether or under which conditions raise (without s) is actually valid. But in my case this compiles succesfully with sphinx.

@cthoyt
Copy link
Contributor

cthoyt commented Jan 23, 2022

You might be missing some darglint configuration to tell it to use sphinx-style docs. Put this in you setup.cfg or darglint config file:

[darglint]
docstring_style = sphinx

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

4 participants