[Python] flake8 - ignore warnings for a function

Discussão em 'Python' iniciado por Stack, Maio 21, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to ignore warning C901 too complex for only a single function. I've tried just about ever permutation of # noqa: C901 I can see and still the error appears. I wouldq think the # noqa comment above the function (method?) be enough. I even tried placing the comment on the same line as the def declaration like so:

    class Klass():

    def my_complex_method(self): # noqa: C901
    """
    lots of if's and return's
    """


    Here is an example of the message I'm getting from flake8:

    src/test/_resource.py:147:5: C901 'Resource.render' is too complex (22)
    def render(self, request): # noqa: C901
    ^


    A quick search only yields how to ignore globally or for the entire file. This is not I want because the other functions in the file I do want to catch if it's too complex. Does anyone know how I can resolve my issue?

    Continue reading...

Compartilhe esta Página