[Python-projects] Another E1101 false positive

Barry Scott barry.scott at onelan.co.uk
Fri Dec 22 16:18:53 CET 2006


Daniel Drake 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.
>
>   
No it does not.

$ python FileB.py
Traceback (most recent call last):
  File "FileB.py", line 3, in ?
    print FileA.funcA()
AttributeError: 'list' object has no attribute 'funcA'

Barry



More information about the Python-Projects mailing list