how to tell pylint to ignore certain imports?

前端 未结 5 1496
耶瑟儿~
耶瑟儿~ 2020-12-29 03:50

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| Unabl         


        
5条回答
  •  生来不讨喜
    2020-12-29 04:48

    [Edit: This is not the wanted solution since a change in the pylint check file is requested, but I leave it in case the code itself can be changed, which can not after a comment]:

    Put a try/except block around the import statement.

    Or even better. something like:

    CONFIG = 'Unix'
    
    
    if CONFIG == 'Unix':
        import  UnixLib
    elif CONFIG == 'Win':
        import  WinLib
    else:
       assert False
    

提交回复
热议问题