pylint ignore by directory

让人想犯罪 __ 提交于 2019-11-29 13:07:26

Adding:

[MASTER]
ignore=migrations

To my .pylintrc works with pylint 0.25. 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
max

You can not give a path but only the "basename" of the directory. E.g. use --ignore=lib instead of --ignore-=appengine-toolkit/gaetk/lib.

Problem is you will ignore all directories named lib.

Although this is an old question it showed up at the top of the list when we were searching stack overflow so i am posting our solution here in the hopes that it might be useful to someone else.

To ignore subdirectories under a directory tree named 3rdparty, we added the following ignore-patterns entry to the [MASTER] entry in .pylintrc.

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
# Ignore all .py files under the 3rdparty subdirectory.
ignore-patterns=**/3rdparty/**/*.py

This fixed the problem for pylint-1.7.1.

We were originally confused by the "base names" clause in the comments. Apparently it does accept paths with wildcards. At least it did for us. Your mileage may vary.

You can then use Bash expansion to your advantage:

--ignore=migrations/{0000..1000}_something
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!