使用 Pylint 按目录忽略 [英] Ignore by directory using Pylint

查看:78
本文介绍了使用 Pylint 按目录忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下内容来自 Pylint 文档:

--ignore=<file>
    Add <file or directory> to the black list. It should be a 
    base name, not a path. You may set this option multiple 
    times. [current: %default]

然而,我没有运气让目录部分工作.

Yet, I'm not having luck getting the directory part work.

我有一个名为 migrations 的目录,其中包含 django-south 迁移文件.当我输入 --ignore=migrations 时,它仍然不断向我显示 migrations 目录内文件中的错误/警告.

I have directory called migrations, which has django-south migration files. As I enter --ignore=migrations, it still keeps giving me the errors/warnings in files inside the migrations directory.

会不会是 --ignore 对目录不起作用?

Could it be that --ignore is not working for directories?

如果我什至可以使用正则表达式来匹配被忽略的文件,它就会起作用,因为 django-south 文件都被命名为 0001_something、0002_something...

If I could even use a regular expression to match the ignored files, it would work, since django-south files are all named 0001_something, 0002_something...

由于我无法通过目录忽略工作,我只好简单地将 # pylint: disable-msg-cat=WCREFI 放在每个迁移文件的顶部,这会忽略所有 Pylint 错误、警告和信息.

Since I could not get the ignore by directory to work, I have resorted to simply putting # pylint: disable-msg-cat=WCREFI on top of each migration file, which ignores all Pylint errors, warnings, and information.

推荐答案

将以下内容添加到我的 .pylintrc 文件适用于 Pylint 0.25:

Adding the following to my .pylintrc files works with Pylint 0.25:

[MASTER]
ignore=migrations

我的问题是 PyDev,它(似乎)不尊重我的设置.我认为,这是由于它为每个文件运行 Pylint,我认为这绕过了忽略"检查——无论是模块/目录还是文件.PyDev 对 Pylint 的调用如下所示:

My problems are with PyDev which (it seems) is not respecting my settings. This is due, I think, to the fact that it's running Pylint per-file, which I think bypasses 'ignore' checks - whether for modules/directories or files. The calls to Pylint from PyDev look like:

/path/to/site-packages/pylint/lint.py --include-ids=y /path/to/project/migrations/0018_migration.py

这篇关于使用 Pylint 按目录忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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