Question

Question is simple, I have two lines in my Python script:

# pylint: disable=C0301, W0212
#!/usr/bin/env python

Both of them have to be on the first line otherwise they will not work.

How do you suggest I resolve this?

Was it helpful?

Solution

The following goes on the first line:

#!/usr/bin/env python

Pylint messages can go on any line. As the documentation says:

Is it possible to locally disable a particular message? This may be done by adding “#pylint: disable=W0123,E4567” at the desired block level or at the end of the desired line of code

So the message needs to be at the same block level (so the second line would work as well as that's the same block / scope). Furthermore the documentation says:

Is there a way to disable a message for a particular module only? Yes, you can disable or enable (globally disabled) messages at the module level by adding the corresponding option in a comment at the top of the file:

So it doesn't say: "first line of the file"; as long as the disable message is at the top of the file then it's fine.

OTHER TIPS

Pylint disable comments do not need to be in the top line to work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top