[red-knot] consider fixing spans related to relative imports #15977
Labels
bug
Something isn't working
diagnostics
Related to reporting of diagnostics.
red-knot
Multi-file analysis & type inference
Description
This issue originally sprouted from here: #15976 (comment)
Consider this Python program:
Running red-knot at present gives you this:
The range here is a little inconsistent with the actual message. The range is only on the module name, but the message includes the preceding
...
. Indeed, if we futz with the Python program a bit more, we can somewhat observe what's going wrong:Gives this:
Here, the diagnostic message is showing something that does not match the actual source code.
I believe the underlying problem is the AST definition of a
from import
:ruff/crates/ruff_python_ast/src/nodes.rs
Lines 291 to 298 in a84b27e
Namely, it normalizes the level based on the preceding dots. But in doing so, this drops the range associated with the dots.
The text was updated successfully, but these errors were encountered: