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
Allow for exceptions for E402 #472
Comments
One improvement would be for |
It seems like a better way might be to have your test code checked with something like |
As I wrote I like E402 so I would prefer to not silence it altogether... Since it seems to support the try/except idiom, I thought this could be added too. But I could live with putting |
It's a similar issue when writing standalone scripts that use Django
I'd find it useful to be able to add #noqa to the |
Closing, see call for pull requests in #480. |
If anyone comes across this issue and would like a fix that doesn't involve noqa on each line, nor to globally disable it, I wrote https://pypi.org/project/flake8-pytest-importorskip/ to handle it "automatically". |
I would not recommend that plugin -- it uses private implementation detail that will break in a future version of |
Yes -- it's a hack. It works for now though.
|
ah, well as the flake8 maintainer -- I plan to change that bit of code so it likely will not work in the future :) |
@asottile If you are changing that, would it be possible to have a plugin change the logical_line that "later plugins" see? |
I really don't think that's a good idea -- lying about the source code to other plugins. plus there's not really a concept of plugin ordering (that your plugin works at all right now is dumb ordering luck) |
I thought ordering was alphabetic - guess just got lucky. |
As for Lying to other plugins: http://pylint.pycqa.org/en/latest/how_tos/transform_plugins.html 😀 |
pylint's system is more for augmenting existing information (giving hints to pylint's engine about information it can't glean statically) -- I don't see how you'd implement your bait-and-switch with a non-import line to an import given that without severely breaking other things |
Yeah, I wasn't being serious anyway. Another perhaps less hacky approach would be to let warnings get filtered by other plugins before being issued. I also have another idea that might work that doesn't need me to look at private state -- I might be able to monkey patch the other plugin function, to wrap it. https://pypi.org/project/flake8-pytest-importorskip/ v1.1.0 has just been released, and this plugin no longer accesses any private state of flake8. |
Hi,
in tests I have quite frequently something like:
which now reports
E402
s.Any chance you add an exception for that? The annoying part is that I’d have to add
noqa
s to every single import statement that comes after theimportorskip()
which would also hamper with unused symbols detection…By itself I find
E402
useful so I don’t want to suppress it either…The text was updated successfully, but these errors were encountered: