Search code examples
djangocode-snippetspylint

Shorthand for pylint "disable-msg" annotation comment?


I'm using pylint on a Django project and I'm finding myself frequently copy-pasting this line:
# pylint: disable-msg=E1101 because of the way pylint works.

I'm fine with this, but it would be nicer if I don't have to copy-paste this every time. Is there are way I can define a shortcut or something? Or in general, how are you guys coping with this?


Solution

  • Not sure I get you right, but if what you want is only a way to put this "disable" comments quick and easy - you can use templates in Eclipse or Live Templates in Pycharm or other similar thing (like macros) in any other good IDE.

    However, why not using other solutions, so that you won't need to use "pylitnt: disable-msg" all the time? For example, you could use "generated-members" setting in rcfile to omit those class fields that are generated by django - well, actually exactly the way one of the answers proposes in the post you mention.

    By the way, pylint has also an option "zope", which disables E1101 error message for all fields that are usually being generated by Zope. You could try submitting feature request for pylint to add similar setting for Django - this option sounds logical for me, as long as there is a similar case already. See this: http://www.logilab.org/card/pylintfeatures#id25