Question

I'm getting many pylint false positive and it seems so ordinary that I cannot imagine it hasn't been solved yet :-/

The following code generates a false positive in pylint since it does not recognise keyword arguments correctly:

class A:
    def __init__(self, *t, x=None):
        if x==1:  # E0601, using variable 'x' before assignment
            x=2
        print(x)

A(x=1)

This is usually due to pylint misinterpreting keyword arguments after a *. Do you know if pylint is still active, where to report it, or how to find if someone has patched this yet? I cannot find something helpful with google :( Maybe by chance, someone knows a patch as it seems to ordinary...

Was it helpful?

Solution

This isn't actually valid Python (at least in 2.x). Specific keyword arguments must go before *args and **kwargs. You'll see an error if you try to paste this into the Python shell. It should look like this:

def __init__(self, x=None, *t):

OTHER TIPS

Do you know if pylint is still active, where to report it, or how to find if someone has patched this yet?

I lurk in the mailing list for Pylint and other logilab projects. It's not very active, but it's not dead yet.

Pylint's bug tracker can be found at http://www.logilab.org/857

There's also an IRC channel mentioned on Pylint's project page: #pylint on FreeNode.

Pylint is not dead at all! The best way to report pb is to file ticket on http://www.logilab.org/project/pylint or the python-projects@logilab.org mailing-list. IRC is fine but is not the preferred way.

Python 3 support is slowly moving on as we don't use it that much yet at Logilab. But as in other open source project, patches are warmly welcome.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top