-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misses comments within multi-line strings and comments #26
Comments
It's not clear to me what that right solution is here. Obviously having such comments within multi-line strings is somewhat unlikely (and potentially undesirable) and users may not want (or be able) to modify their strings to add the relevant codes. Given that and my unusual use case (code within the strings) this may be something that's better just documented as a limitation/known behaviour rather than actually changing? |
A comment inside a multiline string isn't really as a comment, it's just part of the string. I'm somewhat surprised flake8 respects the You can put a e.g.
works as expected. |
Huh, thanks for the tip about putting the comment after the string -- that didn't occur to me. |
Flake8 will happily complain about e.g: these long lines:
and adding a noqa marker to it will silence the error:
yet
flake8-noqa
(withflake8 demo.py --noqa-require-code
) won't complain about thenoqa
comments not having codes.The inverse is also true -- noqa comments in comments and multi-line strings which are unnecessary are also overlooked.
My use-case was in tests for a flake8 plugin, where I've got code snippets in multi-line strings. In this case, having noqa comments within the strings does actually make sense, though I realise that may not always be the case.
The text was updated successfully, but these errors were encountered: