You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
The analyzer incorrectly accepts relative imports in cases where the path is relative to a root but not to the importing file.
Consider the following case:
Directory structure:
src
|->module
|--->init.py
test.py
PYTHONPATH=src
test.py contains the following code:
from .module import Foo
This import should be flagged as invalid because the path ".module" should be relative to the test.py file. However, the code in PathResolverSnapshot.GetImportsFromRelativePath considers all of the root search directories when it performs its search. It therefore finds an import match when it shouldn't.
I think the problem is in PathResolverSnapshot.RootContains. It doesn't do anything to validate that the specified lastEdge starts in the same location as the root. If the relative path happens to match items within that root, the method returns true. If the relative path is zero length, all roots return true.
A proposed fix is to add the following piece of code to PathResolverSnapshot.RootContains before the while loop: