I develop software for Windows, but I work on Linux machines. So, when my code contains imports that are specific to Windows, pylint complains unjustly.
I could use pylint --disable=F0401, but that is just dumb and blind. Instead I hacked a little bit inside pylint imports.py and my little suggestions is the following:
262 def get_imported_module(self, modnode, importnode, modname):
+263 import sys
+264 ignoreModules = ['_winreg', 'your', 'bogus','module','name']
+266 if sys.platform =='linux2' and modname not in ignoreModules:
267 return importnode.do_import_module(modname)
268 except astng.InferenceError, ex:
269 if str(ex) != modname:
270 args = '%r (%s)' % (modname, ex)
And now pylint does not complain about import _winreg.
This should be extended to the other direction, so that windows developers (poor them...)
can avoid error about specific unix modules.
The best ofcourse would be to include an option in .pylintrc to have a list of imported modules
which are ignored.
It's also possible that this option already exists and I just missed it in the documentation.
(P.S I am using: