[red-knot] Fix relative imports in src.root#15990
Conversation
d3dd1ee to
8f08246
Compare
| from crates.ruff_linter.resources.test.cpython.Lib.typing import reveal_type | ||
|
|
There was a problem hiding this comment.
not sure what this is doing here :P
| from crates.ruff_linter.resources.test.cpython.Lib.typing import reveal_type |
There was a problem hiding this comment.
lol, Pycharm tried to be clever
There was a problem hiding this comment.
Thanks for catching this
8f08246 to
a1e265d
Compare
|
I think this change is not correct? Python does not actually allow this at runtime. It seems like a bug in pyright if it allows it. If I create these two files:
x = 1
from .lib import xThe result of The tomllib modules actually exist within a |
|
Hmm true. I'll revert tomorrow and add an explicit test for it. I didn't consider testing it, I trusted Pyright but it seems I shouldn't have. |
…e root of a search path (#16001) ## Summary This PR reverts the behavior changes from #15990 But it isn't just a revert, it also: * Adds a test covering this specific behavior * Preserves the improvement to use `saturating_sub` in the package case to avoid overflows in the case of invalid syntax * Use `ancestors` instead of a `for` loop ## Test Plan Added test
Summary
Fixes #15989
Red Knot failed to resolve relative imports if the importing module is located at a search path root.
The issue was that the module resolver returned an
Err(TooManyDots)as soon as the parent of the current module isNone(which is the case for a module at the search path root).However, this is incorrect if there's a
tail(a module name).Test Plan
Added mdtests