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

DOC203 reported even when type hints in docstring are disabled #50

Closed
JenSte opened this issue Jul 19, 2023 · 3 comments · Fixed by #51
Closed

DOC203 reported even when type hints in docstring are disabled #50

JenSte opened this issue Jul 19, 2023 · 3 comments · Fixed by #51

Comments

@JenSte
Copy link
Contributor

JenSte commented Jul 19, 2023

When --type-hints-in-docstring False is passed, I'd expect that the check for DOC203 is skipped. With no type from the docstring to compare against, the check can never succeed.

$ pydoclint --version
pydoclint, version 0.1.1
$ cat foo.py 
def foo(i: int) -> int:
    """Calculate something.

    :param i: Some argument.
    :return: Some result.
    """
    return 2 * i
$ pydoclint --style sphinx --type-hints-in-docstring False foo.py 
Skipping files that match this pattern: \.git|\.tox
foo.py
foo.py
    1: DOC203: Function `foo` return type(s) in docstring not consistent with the return annotation. Return annotation types: ['int']; docstring return section types: ['']
@jsh9
Copy link
Owner

jsh9 commented Jul 20, 2023

Hi @JenSte , thanks for reporting this issue!

You ran into this issue because the naming of the option is confusing.

It should have been --arg-type-hints-in-docstring rather than --type-hints-in-docstring.

I made a code change, and now if you run this command pydoclint --style sphinx --type-hints-in-docstring False foo.py, you'll see this error message:

The option `--type-hints-in-docstring` has been renamed; please use `--arg-type-hints-in-docstring` instead

Then if you run pydoclint --style sphinx --arg-type-hints-in-docstring False foo.py, you'll see this violation:

    1: DOC203: Function `foo` return type(s) in docstring not consistent with the return annotation. Return annotation types: ['int']; docstring return section types: ['']

And to supress DOC203, this is what you can do:

pydoclint --style sphinx --arg-type-hints-in-docstring False --check-return-types False foo.py

@jsh9 jsh9 closed this as completed in #51 Jul 20, 2023
@JenSte
Copy link
Contributor Author

JenSte commented Jul 20, 2023

Thanks for taking care of this so fast!

Are you planning to release 0.1.2 soon? It already shows up in the change log, but not on PyPI.

@jsh9
Copy link
Owner

jsh9 commented Jul 21, 2023

Thanks for taking care of this so fast!

Are you planning to release 0.1.2 soon? It already shows up in the change log, but not on PyPI.

Hi @JenSte , thanks for the reminder! I forgot to publish a new release yesterday.

It requires a manual publish, so sometimes people forget about it. GitHub probably can improve the user experience here a bit.

It is now published.

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

Successfully merging a pull request may close this issue.

2 participants