-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
Ignore warnings on block of lines #324
Comments
In GitLab by @asottile on Nov 23, 2019, 09:59 I'd rather not if possible Have you tried |
In GitLab by @Volopas on Nov 23, 2019, 12:36 Thanks, so we can ignore some particular warnings on a per-file basis and use inheritance to extend the list down the hierarchy. That'll be definitely helpful for me in the future. It's a pity though we cannot mark a code fragment larger than a couple of lines and smaller than a file in a concise manner. I wouldn't like to ignore E402 entirely for the file, I'd rather follow it with this particular case excluded. It seems you see some flaws in inline ignores that make them somewhat unwanted. What's your opinion on the matter? |
In GitLab by @asottile on Nov 25, 2019, 08:13 I'm mostly hesitant because there's already working solutions to this problem and implementing the suggested feature would be potentially complicated (and something we'd have to support for forever). The inclusion/exclusion/ignore functionality is already some of the most complicated parts of I think inline ignores are fine as is for 99.9% of cases -- the case you're suggesting is particularly exceptional in my opinion (and as such I'm hesitant to implement a big complex feature for it) |
In GitLab by @Volopas on Nov 25, 2019, 17:20 I agree the feature is not very crucial and more of refinement than of real necessity. I don't think the case is extremely rare, but neither the feature is worth a lot of effort. Thank you. |
In GitLab by @Volopas on Nov 25, 2019, 17:20 closed |
In GitLab by @asottile on Nov 25, 2019, 20:14 thanks for the issue though -- if it becomes easier to implement in the future (I hope it will!) we'll consider this :) |
In GitLab by @sigmavirus24 on Nov 26, 2019, 05:04 Also worth noting that the way that Flake8 works today it might not be awful to implement. We have the ability to have a StyleGuide per file. I suspect we could do something hacky on the fly and copy that with the block settings but that requires far more awareness and would require a fundamental change of where we decide whether to report an error or not (based on config) |
Please reconsider this 🙏 |
In GitLab by @Volopas on Nov 23, 2019, 08:37
When we add special comments with
noqa
keyword, we can ignore either an exact line of code, or the entire file, but there is no way to ignore several lines of code without being too verbose. Nor can one ignore some but not the other warnings on the entire file.I like how eslint tackles the whole issue. They have comments 1) able to ignore all at the same time or specific warnings; 2) the entire file, a code fragment, a current line or the one next to a current line. So their system is both flexible and complete.
The specific problem I have making me start the issue is that I have to have a bunch of lines with module-level
import
, not at the top of the file (E402). It looks like that:I wouldn't like disabling E402 entirely because that's just a necessary exclusion. But I can only disable E402 warning either in every single line of the block (3) or in the entire file. Both choices seem ugly or missing the point.
It would be great if flake8 would get more flexible in this way. Thank you for your efforts and for an undoubtedly useful tool.
The text was updated successfully, but these errors were encountered: