Pylint: Disable specific warnings for specific fol

2019-03-17 23:35发布

We have a Python project laid out like this:

project/
├── .pylintrc
├── module1.py
├── module2.py
└── tests/
    ├── test_module1.py
    └── test_module2.py

Our unit and function tests reside in the folder called tests/. When it comes to tests the pylint warnings missing-docstring, invalid-name and protected-access are not relevant. On the other hand, these warnings are very useful for the actual code in the project.

My question is whether it is possible to add ignores for missing-docstring, invalid-name and protected-access in the .pylintrc-file that apply to modules in the tests/-folder only?

If possible, we do not want to add #-disables for these warnings to every test-module inside the folder.

标签: python pylint
1条回答
Juvenile、少年°
2楼-- · 2019-03-18 00:28

As far as I'm aware you can't disable specific warnings for entire directories or files.

However, you can disable all warnings for specific directories using the following on the command line:

--ignore=<file[,file]>

The file here can be a directory.

Personally, and I know you said you'd rather not, I'd add a disable to the top of each file.

查看更多
登录 后发表回答