Skip to content Skip to sidebar Skip to footer

How To Tell Flake8 To Ignore Comments

I'm using flake8 in emacs in order to clean up my python code. I find it annoying to have my comments flagged as errors (E501 line too long (x > 79 characters)). I'm wondering i

Solution 1:

I've figured out a possible solution to this, but there might be something better. If you write a comment that will raise an E501 error, i.e. it is too long, you can append that line with # noqa: E501, and flake8 will ignore it. For example:

# This is a really really long comment that would usually be flagged by flake8 because it is longer than 79 characters

would usually raise an E501, but

# This is a really really long comment that would usually be flagged by flake8 because it is longer than 79 characters # noqa: E501

will not.

documented here.

Solution 2:

You can change the list of codes ignored by flake8 using a configuration file. For example, in your project directory create a file named .flake8 with the following content:

[flake8]
per-file-ignores =
    # line too long
    path/to/file.py: E501,

This may be easier than using # noqa comments.

Post a Comment for "How To Tell Flake8 To Ignore Comments"