如何告诉pylint忽略某些进口? [英] how to tell pylint to ignore certain imports?

查看:49
本文介绍了如何告诉pylint忽略某些进口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Python 为 Windows 开发软件.我正在 Linux 上开发,并且正在使用Pylint 检查我的代码.我无法摆脱错误:

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'   

这很明显——Linux 上的 Python 没有这个模块.

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

那么,我必须在 .pylintrc 中放入什么才能忽略此错误?

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

提前致谢,盎司

文档说:

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

现在我需要找到如何使用它...

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

部分解决方案:

pylint --disable=F0401 <filename>

我仍在寻找通过 .pylintrc 实现的方法.

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

推荐答案

使用以下代码也可以解决这个问题:

Just run into this as well with the following code:

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

pylint 构建失败,出现此错误:

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

解决方案pylint 0.10:

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

这篇关于如何告诉pylint忽略某些进口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆