简体   繁体   中英

Is it possible to ignore one single specific line with pylint, without changes to the source code?

Is it possible to ignore one single specific line with pylint? has solutions that requires littering source code with comments what is undesirable for me.

Is there way to specify that given instance is false positive in arguments of the pylint command line tool?

I don't think it is possible to ignore a specific line without changing the source code. However, it is certainly possible to ignore warning types in the .pylintrc or at the top of file.

I'd go with the approach of creating a .pylintrc to suit your needs. For example, if you want to completely ignore W0612: unused-variable then you can create a .pylintrc file and add message names to disable as noted in pytest docs .

.pylintrc

disable=unused-variable,
..., 

Alternatively, you can disable messages on a case by case basis at the top of the file , and just tell your students to ignore it:

Top of file

# pylint: disable=unused-variable, wildcard-import, method-hidden
# pylint: enable=too-many-lines

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM