使用运行 Python 2 的 Pylint 检查 Python 3 源代码 [英] Check Python 3 source with Pylint running with Python 2

查看:122
本文介绍了使用运行 Python 2 的 Pylint 检查 Python 3 源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Pylint 的一些检查取决于检查的源代码是 Python 2 还是 Python 3.例如,请参阅 如何避免 Python 3 中继承类的构造函数的 Pylint 警告?.

Some checks of Pylint are depending on whether the checked source code is of kind Python 2 or Python 3. E.g., see How to avoid Pylint warnings for constructor of inherited class in Python 3?.

在我的设置中,我在使用 Python 2.7 的开发服务器上运行 Pylint.但是,我使用 Pylint 在每次提交时自动检查 Python 3 代码.

In my setup I run Pylint on a development server, which is using Python 2.7. However, I use Pylint to automatically check Python 3 code on each commit.

如何配置 Pylint 以执行 Python 3 的检查,即使它在 Python 2 下运行?

How can I configure Pylint to perform checking for Python 3, even if it runs under Python 2?

推荐答案

简短的回答:你不能.

Pylint 使用内置的 Python 解析器,并且也按需获取标准库信息,因此运行 Pylint 的 Python 版本对其输出影响很大.

Pylint is using the builtin Python parser, and also get standard library information on demand, so the Python version running Pylint has a high impact on its output.

如果您想使用 Pylint 来检查 Python 2 和 Python 3 代码,您应该安装多个 Pylint.

You should have several Pylint installations if you want to use it to check both Python 2 and Python 3 code.

这篇关于使用运行 Python 2 的 Pylint 检查 Python 3 源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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