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

RFE: warn about disables using identifiers, promote symbolic names #3250

Closed
scop opened this issue Nov 17, 2019 · 7 comments
Closed

RFE: warn about disables using identifiers, promote symbolic names #3250

scop opened this issue Nov 17, 2019 · 7 comments

Comments

@scop
Copy link
Contributor

scop commented Nov 17, 2019

Is your feature request related to a problem? Please describe

Would be nice to have a way to pylint emit warnings for pylint disable=... lines that use message identifiers as opposed to their symbolic names in code. The symbolic names can mostly be just understood when reading related code, whereas identifiers require one to look them up.

Describe the solution you'd like

A warning message if one uses for example # pylint disable=W0612 containing a suggestion to use disable=unused-variable instead.

Additional context

I think I can have a look at implementing this sometime unless someone beats me to it, but posting this RFE to probe acceptability/desirability first.

@PCManticore
Copy link
Contributor

Hey @scop

Thank you for creating an issue! We already support this pattern with use-symbolic-message-instead. It is disabled by default though as it is an informational check, so you have to enable it explicitly:


python -m pylint a.py --enable=use-symbolic-message-instead
************* Module a
a.py:1:0: I0023: Id 'C0114' is used to disable 'missing-module-docstring' message emission (use-symbolic-message-instead)

@scop
Copy link
Contributor Author

scop commented Nov 17, 2019

Oh, cool. However informational messages don't seem to cause a nonzero exit status, which I would like for this message. Is there a way to accomplish that?

@PCManticore
Copy link
Contributor

There isn't a way to accomplish this I'm afraid, other than promoting this check to a different category in pylint itself.

@scop
Copy link
Contributor Author

scop commented Nov 17, 2019

Ok, filed #3251 for the confurability :)

@dbaty
Copy link
Contributor

dbaty commented Jan 23, 2020

For the record, a colleague of mine (@xavfernandez) recently released a pylint plugin that registers such a warning message. The documentation is a bit short for now, but basically one just needs to:

  1. Add pylint-message-id to your requirements.

  2. And add the following line to the .pylintrc:

    load-plugins=pylint_message_id
    

And you get the following warnings:

file.py:5: [C9001(numerical-message-id), ] Numerical message identifier used: W0123 - use eval-used instead

@xavfernandez
Copy link

xavfernandez commented Jan 24, 2020

For the record, a colleague of mine (@xavfernandez) recently released a pylint plugin that registers such a warning message.

I did not know about use-symbolic-message-instead 😿 .

Since then, I've opened #3363 and its patch-plugin pylint-strict-informational so this becomes:

  1. Add pylint-strict-informational to your requirements.

  2. And add the following lines to the .pylintrc:

    load-plugins=pylint_strict_informational
    enable =
        use-symbolic-message-instead
    

@scop
Copy link
Contributor Author

scop commented Jan 24, 2020

Very nice, thanks!

scop added a commit to home-assistant/core that referenced this issue Jan 24, 2020
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

No branches or pull requests

4 participants