pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.33k stars 1.14k forks source link

zmq no-member false positives even with extension loading enabled #478

Open pylint-bot opened 9 years ago

pylint-bot commented 9 years ago

Originally reported by: Chris Rebert (BitBucket: cvrebert, GitHub: @cvrebert?)


Testcase file:

#!python

# qux.py 
from __future__ import print_function
import zmq

print(zmq.POLLIN)

Relevant portion of my pylint.rc:

#!ini

# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=yes

# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=zmq,qux

However, pylint still doesn't seem to be loading zmq:

#!bash

$ pip install pyzmq==14.5.0
<succeeds>
$ pylint --rcfile=pylint.rc -r n -f parseable qux.py 
Warning: option include-ids is deprecated and ignored.
Warning: option symbols is deprecated and ignored.
************* Module qux
qux.py:1: [C0111(missing-docstring), ] Missing module docstring
qux.py:4: [E1101(no-member), ] Module 'zmq' has no 'POLLIN' member
$ python qux.py 
1
$

I am using bleeding-edge pylint & astroid, pip-installed from the mercurial repos.

#!bash

$ pylint --version
No config file found, using default configuration
pylint 1.4.1, 
astroid 1.3.4, common 0.63.2
Python 2.7.9 (default, Feb 13 2015, 20:19:10) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)]

pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Well, I don't think extension-pkg-whitelist helps when they have this code: https://github.com/zeromq/pyzmq/blob/master/zmq/backend/__init__.py#L15. Pylint can't understand from where POLLIN is coming in this situation. Most probably this will need an astroid brain tip.