12

Suppose I have a file with a heredoc with long lines:

    some_string = '''
very long lines here, 20 lines each of length 500
'''

How do I ignore all the flake8 "line too long" errors in that heredoc, without excluding the entire file from checking?

This answer describes # noqa for a single line, but I can't put that in the heredoc. The manual does not seem to describe ignoring a chunk of code.

dfrankow
  • 20,191
  • 41
  • 152
  • 214
  • Why do you have such long lines in the first place? Is it possible you could put them in a separate txt file instead? – wjandrea Aug 07 '21 at 01:28
  • 2
    Could, but for a unit test, it's much more readable to just have the example right there. It's not actually length 500, it's more like 100. I just didn't want people to tell me to fiddle with the line length. – dfrankow Aug 07 '21 at 15:30

1 Answers1

25

Oh oops, I found the answer. I can put # noqa at the end of the heredoc:

    some_string = '''
very long lines here, 20 lines each of length 500
'''  # noqa

I feel silly.

dfrankow
  • 20,191
  • 41
  • 152
  • 214