Search code examples
pythonpylint

How do you properly add an unnecessary indent (for organisational purposes) in Python without pylint complaining?


I'm currently using

if True:
    ...

in order to add an extra indentation for organisational purposes but that will make pylint complain about using-constant-test. Is there some kind of proper statement in Python for this situation (something like pass) without abusing the if statement like this?

This is not a duplicate of this other question since that was not concerned with pylint.


Solution

  • If you just want the message to stop annoying you, you can disable it with a comment, either throughout the file:

    # pylint: disable=using-constant-test
    if True:
        ...
    

    or just for that line:

    if True:  # pylint: disable=using-constant-test
        ...