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

useless-type-doc conflicts with mypy no-untyped-def, unsure how to proceed #4117

Closed
nth10sd opened this issue Feb 22, 2021 · 4 comments · Fixed by #4614
Closed

useless-type-doc conflicts with mypy no-untyped-def, unsure how to proceed #4117

nth10sd opened this issue Feb 22, 2021 · 4 comments · Fixed by #4614
Assignees
Labels
Enhancement ✨ Improvement to a component False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@nth10sd
Copy link

nth10sd commented Feb 22, 2021

With pylint 2.7.0, we now have the useless-type-doc check. I also have disallow_untyped_defs = True turned on for mypy.

I have some functions with unused variables that I append a _ to the name, e.g. _name and set a type to them. pylint 2.7.0 now throws useless-type-doc error, and when I remove the type, mypy throws the no-untyped-def error.

What's the best way forward? Should I change the mypy config, or should I ignore this pylint error?

This worked with pylint 2.6.x, since it does not have the useless-type-doc check.

@Pierre-Sassoulas
Copy link
Member

Hello, thank you for opening the issue.

Do you have a code example so I can understand the problem better ?

(You can disable the pylint message with # pylint: disable=useless-type-doc for now in order to not be stuck in an infinite loop while we figure this out.)

@Pierre-Sassoulas Pierre-Sassoulas added the Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning label Feb 22, 2021
@nth10sd
Copy link
Author

nth10sd commented Feb 22, 2021

Sample:

"""module docstring"""


def test(_new) -> str:
    """foobar

    :return: comment
    """
    return ""


def main() -> None:
    """main function"""
    test("")

I have the following settings:

mypy.ini : disallow_untyped_defs = True or use --disallow-untyped-defs in CLI
.pylintrc:

[MASTER]
load-plugins=pylint.extensions.docparams,

[PARAMETER_DOCUMENTATION]
accept-no-param-doc=no
accept-no-raise-doc=no
accept-no-return-doc=no
accept-no-yields-doc=no
$ mypy --disallow-untyped-defs start.py
start.py:4: error: Function is missing a type annotation for one or more arguments
Found 1 error in 1 file (checked 1 source file)
$ pylint --rcfile=../.pylintrc start.py
$

However, when I change the test() function definition line to def test(_new: str) -> str:

$ mypy --disallow-untyped-defs start.py
Success: no issues found in 1 source file
$ pylint --rcfile=../.pylintrc start.py
************* Module start
start.py:4:0: W9020: "_new" useless ignored parameter type documentation (useless-type-doc)

I'm guessing these two settings --disallow-untyped-defs and useless-type-doc are naturally incompatible with each other?

$ pylint --version
pylint 2.7.0
astroid 2.5
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0]
$ mypy --version
mypy 0.812

@nth10sd
Copy link
Author

nth10sd commented Jun 7, 2021

I'm still hitting this in pylint 2.8.3 and astroid 2.5.6 (I have ignore lines though). I've updated my settings file above, as I had regrettably missed this part out:

[MASTER]
load-plugins=pylint.extensions.docparams,

@Pierre-Sassoulas do you mind testing to see if you can reproduce this?

@Pierre-Sassoulas
Copy link
Member

I had some time to look at this, I think this is a false positive in pylint, Another issue for this is #4593

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code Enhancement ✨ Improvement to a component and removed Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning labels Jun 25, 2021
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants