pylint-pytest
pylint-pytest copied to clipboard
unused-import warnings on Windows
On Windows, importing fixtures can still raise unused-import warnings.
In my case, this happens when linting with VSCode.
Debugging revealed that the bug is within pylint_pytest.utils._is_same_module(...):
if inspect.getmodule(fixture.func).__file__ == \
import_from.parent.import_module(import_from.modname,
False,
import_from.level).file:
The comparison is done without case normalization. However, Windows paths are case-insensitive.
In my case, the first path begins with c:\, whereas the second one begins with C:\.
Edit: Apparently, I don't have the permission to create a branch. But a simple solution would be: Normalize both paths with os.path.normcase before comparing them.