Hello
I'm getting false positives in a, I confess, quite bizzare case (testcase
below).
Short story is that I have some dynamically generated python extension module
(C++). I also have lots of tests in python and some of them are using the
extension module. I run pylint and pytest on these tests and everything is ok up
to a point:
sometimes I'm unable to deliver this C++ extension module. In such case some of
the tests fail pytest/pylint verification due to unresolved imports.
I decided it's the best to use 'stub' extension module, written in python, when
it is not possible to provide the C++ based one. Since the C++ module is
dynamically generated and it contains lots of classes/functions it is not
feasible to define then in the stub module. Instead, I decided to write a
generic python module, which defines "everything". This works fine with python
and pytest, but pylint still complains.
I don't know if this behavior can be fixed in pylint. Any ideas how to deal with
this problem (maybe mod.py could be written differently?)?
Testcase:
files:
------ mod.py -------
import sys
class FakeModule:
def __getattr__(self, x):
return None
sys.modules[__name__] = FakeModule()
------ test.py -------
from mod import Whatever
import mod
a = mod.Spam
if Whatever is None and a is None:
print 'wow! this works'
"python test.py" output:
wow! this works
pylint's output:
************* Module test
E0611: 1: No name 'Whatever' in module 'mod'
E1101: 3: Module 'mod' has no 'Spam' member
setup:
pylint 0.21.1,
astng 0.20.1, common 0.50.3
Python 2.4.3 (#1, Sep 17 2008, 16:07:08)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-41)]
regards,
Jakub Zytka
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects