Is there some magic to adding new messages to pylint? I've defined my new warning in checkers/classes.py by adding a new key/value pair to the MSGS dict: MSGS = { ... 'W0234': ('instance attribute %r is not used within the class', 'defined-attribute-not-accessed', 'Used when an attribute defined by the class is not accessed \ by the class itself.'), } but when I try to disable my new warning (W0324) with something like "# pylint: disable=C0302,W0324", it complains: E: 1: Bad option value 'W0324' Is there some sort of message compilation step which gathers all the keys from the MSGS dictionaries? I looked for all the places where "W0233" appeared, and tried to mimic that, but that would seem not to have been sufficient. I can see by the tracebacks that it is getting my new code. In fact, when I am unable to disable W0234, the checker emits the unused messages I'm trying to suppress, e.g.: W:113:ClassLevelMessage: instance attribute 'attr0' is not used within the class so I know my new code is being executed. Thx, Skip
On Fri, Jul 05, 2013 at 09:49:27PM -0500, Skip Montanaro wrote:
Is there some magic to adding new messages to pylint? I've defined my new warning in checkers/classes.py by adding a new key/value pair to the MSGS dict:
MSGS = { ... 'W0234': ('instance attribute %r is not used within the class', 'defined-attribute-not-accessed', 'Used when an attribute defined by the class is not accessed \ by the class itself.'),
}
but when I try to disable my new warning (W0324) with something like "# pylint: disable=C0302,W0324", it complains:
E: 1: Bad option value 'W0324'
So is it 2-3-4, or 3-2-4? Marius Gedminas -- A: No. Q: Should I include quotations after my reply?
Aside from Marius's point about the typo, you also need to make sure it is added to the @check_messages decorator. -m
Aside from Marius's point about the typo, you also need to make sure it is added to the @check_messages decorator.
Thanks. I would never have guessed that. Looking in checkers/classes.py, I see 22 messages defined in the MSGS dict, but only two are mentioned, in a single use of the check_messages decorator. I must be missing something. Skip
On 07 juillet 21:06, Skip Montanaro wrote:
Aside from Marius's point about the typo, you also need to make sure it is added to the @check_messages decorator.
Thanks. I would never have guessed that. Looking in checkers/classes.py, I see 22 messages defined in the MSGS dict, but only two are mentioned, in a single use of the check_messages decorator. I must be missing something.
Well, the pb is that when some visit methods interact with each others, it's not always that easy to properly decorate those methods: the idea of this decorator is that when some message is disabled, you don't want to call the method at all to speed up things, rather than simply not printing out the message. Wrt the classes checkers, the pb is that visit method (visit_* / leave_*) are responsible to emit messages but also to handle a shared state that is used by other methods, hence may only be disabled if almost all messages for this checker are disabled. So, if you don't mind this shared state, the best thing to do is to have your own checker class. Also notice you may have several checker with the same name, eg 'classes'. FYI, messages ids will probably disappear at some point in favor of the new symbolic names which are much more readable and easier to remember. -- Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42) Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services CubicWeb, the semantic web framework: http://www.cubicweb.org
participants (4)
-
Marius Gedminas
-
Martin Pool
-
Skip Montanaro
-
Sylvain Thénault