[Python-projects] Another E1101 false positive

Chris Mellon arkanes at gmail.com
Fri Dec 22 16:13:56 CET 2006


On 12/22/06, Daniel Drake <ddrake at brontes3d.com> wrote:
> This is certainly bad coding practice (defining a variable with the same
> name as an import) but pylint is misinterpreting what happens here.
>
> FileA.py:
>
>         def funcA():
>             return 4
>
> FileB.py:
>
>         import FileA
>         FileA = [1,2,3]
>         print FileA.funcA()
>
>
> Run pylint on FileB:
>
>         E1101:  6: Instance of 'list' has no 'funcA' member
>
> However, run FileB through python:
>
>         4
>
>
> In other words: when a variable is named the same as an import, python
> uses the import, but pylint interprets the code as if it is using the
> variable.
>
> Daniel
>
>

I'm not sure how you got Python to do that, because that's not correct
behavior. Pylint gets it right - rebinding FileA in the global
namespace shadows the import. I've confirmed that what Pylint predicts
is what happens with Python 2.4.4 on Windows XP.



More information about the Python-Projects mailing list