1

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...

3 Answers 3

3

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):
Sign up to request clarification or add additional context in comments.

3 Comments

def __init__(self, *t, x=None) is perfectly valid in Python 3. x is known as a keyword-only argument. See PEP 3102.
Oh, does that mean I'm using Python 3 specials?
@MariusGedminas I wasn't aware of that. Edited to clarify that my answer applies to 2.x only.
2

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.

1 Comment

Oh, so what's correct the way to report it and is there any chance of this getting fixed any time? :)
1

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 [email protected] 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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.