PyCQA/pylint

How can I disbale checkers from line 100 to line 200 #8146

ramwin posted onGitHub

Current problem

I'm working on a very old project. There are thousands of lines of code in a file, e.g. tasks.py. Now I'm adding a new class MyTask to it. The structure looks like this:

<old block>
def old_function1():
    ...
class OldTask1:
   ...

<from line 5000 is my code>
class MyTask:
   ....

When I use pylint, a lot of errors will be printed. I only want pylint to check my new code.

Desired solution

I want some special comment to disable the pylint or enable it totally. So I can write the code like this.

# pylint: disable=all, until=forever  maybe if unitl=400, then only next 400 lines will not be checked.
<old block>
def old_function1():
    ...
class OldTask1:
   ...

<from line 5000 is my code>
# pylint: enable=all, until=forever
class MyTask:
   ....

Then, all other errors messages will disappear. I can focus the errors in my code.

Additional context

No response


pylint: disable=my-message on line 100, then pylint: enable=my-message on line 200 should work, or did I misunderstand ? You can also create a new file for the new code, it doesn't sound like it would hurt :)

posted by Pierre-Sassoulas almost 2 years ago

You are right, but this can only ignore some specific errors. How can I ignore all kind of errors?
Due to some rules, I can only put the MyTask class in the same file.

pylint: disable=my-message on line 100, then pylint: enable=my-message on line 200 should work, or did I misunderstand ? You can also create a new file for the new code, it doesn't sound like it would hurt :)

posted by ramwin almost 2 years ago

You can use # pylint: disable=C,E,W,R

posted by Pierre-Sassoulas almost 2 years ago

Thanks a lot, it works.

posted by ramwin almost 2 years ago

Fund this Issue

$0.00
Funded

Pull requests