ruff icon indicating copy to clipboard operation
ruff copied to clipboard

[red-knot] invalidation on file change doesn't work in CLI with relative paths

Open carljm opened this issue 1 year ago • 3 comments

Given these files:

# main.py
from typing import override
from base import B

foo = override

class C(B):
    @foo
    def method(self): pass

# base.py
class B: pass

# typing.py
def override(func):
    return func

Running cargo run --bin red_knot path/to/that/dir/main.py correctly gives a bad-override diagnostic.

If we remove the @foo line in main.py and re-run the CLI from start, it correctly does not give a diagnostic.

But in either case if we add or remove the @foo line while the CLI is still running, it appears to re-execute some queries, but it fails to correctly account for the change (the diagnostic remains present or absent as it was on the first run, disregarding the change.)

carljm avatar Jul 05 '24 16:07 carljm

From the traces after the file change, it looks like it's just not recognizing the file has been modified at all; there are some file_system queries but no semantic index of main.py or anything else.

carljm avatar Jul 05 '24 16:07 carljm

It looks like this is a path normalization issue. Invalidation works correctly if I run cargo run --bin red_knot /absolute/path/to/the/dir/main.py, but fails if I run cargo run --bin red_knot ../path/to/the/dir/main.py.

carljm avatar Jul 05 '24 17:07 carljm

Possibly related https://github.com/astral-sh/ruff/issues/11907

MichaReiser avatar Jul 05 '24 19:07 MichaReiser