Disable pylint message for a given module or directory

后端 未结 2 1811
离开以前
离开以前 2020-12-19 03:32

Is there a way to disable Pylint\'s duplicate-code message just for test files? All of the tests in our project are DAMP so the duplicated code is by design. I

2条回答
  •  囚心锁ツ
    2020-12-19 03:57

    There is the --disable or -d message control flag that can be used to selectively disable messages when called. You could therefore disable this message for all files under the test folder by running pylint on those files from within the project folder:

    pylint -d duplicate-code test/
    

    I was able to verify that I can cut out specific messages from all files in the directory, although I was not getting duplicate code errors and so could not check for that message.

    You could also put this into a script that you run from your project's main directory. Something like:

    #!/bin/bash
    pylint src/
    pylint -d duplicate-code test/
    

    Alternatively, you could add # pylint: disable=duplicate-code to the top of each of the files for which you want to exclude these messages. It looks like that is about as far as file-wise selective exclusion flags goes for pylint.

提交回复
热议问题