Search code examples
pythonpylint

how to tell pylint to ignore certain imports?


I'm developing software for Windows with Python. I am developing on Linux, and I am using Pylint to check my code. I can't get rid of the error:

F| Unable to import '_winreg'   

This is obvious - Python on Linux does not have this module.

So, what do I have to put in my .pylintrc to ignore this error?

Thanks in advance, Oz

EDIT:

Documentation says:

:F0401: *Unable to import %r*
  Used when pylint has been unable to import a module.

Now I need to find how to use it ...

Partial solution:

pylint --disable=F0401 <filename>

I am still looking for a way to do via .pylintrc.


Solution

  • Just run into this as well with the following code:

     8: if os.name == 'nt':
     9:    import msvcrt
    10: else:
    11:    import fcntl
    

    pylint failed the build with this error:

    E:  9, 4: Unable to import 'msvcrt' (import-error)
    

    The solution is available since pylint 0.10:

     9:    import msvcrt  # pylint: disable=import-error