Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

unused-import warnings on Windows #28

Open
zumgruenenbaum opened this issue Dec 8, 2021 · 0 comments
Open

unused-import warnings on Windows #28

zumgruenenbaum opened this issue Dec 8, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@zumgruenenbaum
Copy link

zumgruenenbaum commented Dec 8, 2021

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.

@zumgruenenbaum zumgruenenbaum added the bug Something isn't working label Dec 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant