Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pylint: How do I cleanly suppress things without subsequent 'suppressed-message' nonsense?

Tags:

python

pylint

I have a file foo.py that makes extensive use of the Faker third-party module. As such, pylint generates a lot of 'no-member' errors.

I would like to disable these in foo.py. So at the top, I tried inserting:

# pragma pylint: disable=no-member

But, in a quite-annoying fashion, pylint now spits out a suppressed message every time it hits one of these errors - completely defeating the purpose of my pragma??

foo.py:1:0: I0011: Locally disabling no-member (E1101) (locally-disabled)
... other misc stuff ...
foo.py:177:0: I0020: Suppressed 'no-member' (from line 1) (suppressed-message)
foo.py:83:0: I0020: Suppressed 'no-member' (from line 1) (suppressed-message)
foo.py:85:0: I0020: Suppressed 'no-member' (from line 1) (suppressed-message)

Huh... well that's... ridiculous.

So I tried to... suppress the suppression messages??

# pragma pylint: disable=no-member,suppressed-message

And THEN it gets even better...

foo.py:1:0: I0011: Locally disabling no-member (E1101) (locally-disabled)
foo.py:1:0: I0011: Locally disabling suppressed-message (I0020) (locally-disabled)
foo.py:1:0: C0102: Black listed name "foo" (blacklisted-name)
.... misc stuff, actual things I should clean up here ...
foo.py:1:0: I0021: Useless suppression of 'suppressed-message' (useless-suppression)

So I guess my question is - how do I make suppression messages go away entirely on a per-file basis, without some annoying replacement message being dropped in?

EDIT: Thank you for the comments.

Output of pylint --version:

pylint 2.1.1
astroid 2.0.4
Python 3.6.5 (default, Apr 25 2018, 14:23:58) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)]
like image 344
Larold Avatar asked Sep 21 '18 18:09

Larold


1 Answers

I-category messages are disabled by default. You turned them on yourself, by setting enable=all in the [MESSAGES CONTROL] section of your pylintrc, and then you didn't disable them in the disable list in the same section. Add suppressed-message to the disable list in your pylintrc, and the suppressed-message messages should stop appearing.

As for the useless-suppression message, that seems to be a pylint bug.

like image 57
user2357112 supports Monica Avatar answered Sep 30 '22 10:09

user2357112 supports Monica