I'm coding in Python3 and using pylint to keep my code clean.
I want to define something like interface class, so I could add more functionality in a clean and concise way, however, pylint gets in the way of this goal.
Here's a sample method:
def on_enter(self, dummy_game, dummy_player): #pylint disable=no-self-use
"""Defines effects when entering area."""
return None
Here's pylint output:
R: 70, 4: Method could be a function (no-self-use)
The question is:
#pylint
comment)? ordummy_game
and dummy_player
EDIT:
Output of pylint --version
:
pylint 1.2.1,
astroid 1.1.1, common 0.61.0
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
[GCC 4.9.1]
Turns out I was lacking colon :
I usedpylint disable=no-self-use
when it should have beenpylint: disable=no-self-use
Well, at least I will always have the latest (and the one built for python3) pylint from now on :)
You are currently ignoring this as
def on_enter(self, dummy_game, dummy_player): #pylint disable=no-self-use
...
Instead do
# pylint: disable=R0201
def on_enter(self, dummy_game, dummy_player):
...
Add a comment to your file like below
# pylint: disable=R0201
You can find the short codes mnemonics to for each of the warnings/errors on documentation here:
no-self-use (R0201)
:Method could be a function Used when a method doesn’t use its bound instance, and so could be written as a function.
In case the whole file contains code for the interface only, you can put this at the top:
# pylint: disable=R0201
class SomeInterface(object):
...
...
In case you have other code as well, and want to disable this for the interface class only, you can enable the check again like
# pylint: disable=R0201
class SomeInterface(object):
...
...
# pylint: enable=R0201
class AnotherClass(object):
...
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With