flake8 disable linter only for a block of code

There isn’t a way in flake8 to ignore a block of code

Your options are:

  1. ignore each line that produces an error by putting # noqa: E501 on it

  2. ignore the entire file (but this turns off all other errors as well) with a # flake8: noqa on a line by itself

  3. ignore E501 in the entire file by using per-file-ignores:

    [flake8]
    per-file-ignores =
         path/to/file.py: E501
    

generally I’d prefer the third one, maybe even sequestering your long-strings into their own file to be ignored


disclaimer: I’m the current flake8 maintainer

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)