-
Notifications
You must be signed in to change notification settings - Fork 8
Ignore unused-import error when importing into conftest.py #2
Comments
Is the use case having fixtures in non-conftest files, or/and importing them from somewhere else into other conftest files only? Apart from that I think disabling the warning there (maybe per line / affected import) is quite OK. Do you suggest that the warning should get disabled by default for conftest modules? This would hide any issues in that regard in general then though. |
I have a fixtures/ folder containing all of my fixtures (there are many). In conftest.py, I import all of these fixtures so that they can be used in all of my test files, but they are not used in conftest.py themselves. They are used across all tests, so having them globally available works well. I was thinking that the warning should be disabled specifically for the module named conftest, but if this would cause other problems, then this issue can be closed. Thanks! |
Thanks for requesting this @TylerYep. To me it sounds like a legit use case if we have many fixtures and want to group them in different modules to avoid one gigantic By leveraging Since @blueyed do you see any potential issue by implementing this FR? If we can make sure we only suppress the |
Noticed the new release, any chance this can be added as well? Thanks :) I can try looking into making a PR if it's not a super fast fix. |
#2 suppressing FP when importing fixtures into conftest
Implemented with #9 |
I get the following pylint error when I try to import my fixtures into conftest.py but do not use them anywhere in the code. However, these unused imports in conftest.py are a special case, because fixtures imported that file are accessible globally in all other test files without needing to import them.
It would be great if this plugin could ignore this error specifically for conftest.py!
The simple workaround is to add at the top of conftest.py:
But I would like to avoid this if possible. Thanks!
The text was updated successfully, but these errors were encountered: