How to ignore flake8 "line too long" errors in a heredoc
Asked Answered
L

1

15

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.

Ladyinwaiting answered 6/8, 2021 at 22:0 Comment(2)
Why do you have such long lines in the first place? Is it possible you could put them in a separate txt file instead?Mercie
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.Ladyinwaiting
L
33

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.

Ladyinwaiting answered 6/8, 2021 at 22:1 Comment(4)
pls don't feel silly, you helped me today :)Antiperiodic
What is the long line is comment?Balf
@Balf I'm sorry, I don't understand the question.Ladyinwaiting
I mean "What if the long line is a comment?" But after second try it turned out it works like expected (put ` # noqa` at the end of long comment), so nevermind.Balf

© 2022 - 2024 — McMap. All rights reserved.