[Python] How to disable pylint no-self-use warning?

Discussão em 'Python' iniciado por Stack, Fevereiro 7, 2025.

  1. Stack

    Stack Membro Participativo

    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:

    1. How do I suppress warning (notice the #pylint comment)? or
    2. How do I tell pylint that this is merely an interface (notice the dummy_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]

    Continue reading...

Compartilhe esta Página