ruff/crates/ruff_db/src
Carl Meyer f22c8ab811
[red-knot] add maybe-undefined lint rule (#12414)
Add a lint rule to detect if a name is definitely or possibly undefined
at a given usage.

If I create the file `undef/main.py` with contents:

```python
x = int
def foo():
    z
    return x
if flag:
    y = x
y
```

And then run `cargo run --bin red_knot -- --current-directory
../ruff-examples/undef`, I get the output:

```
Name 'z' used when not defined.
Name 'flag' used when not defined.
Name 'y' used when possibly not defined.
```

If I modify the file to add `y = 0` at the top, red-knot re-checks it
and I get the new output:

```
Name 'z' used when not defined.
Name 'flag' used when not defined.
```

Note that `int` is not flagged, since it's a builtin, and `return x` in
the function scope is not flagged, since it refers to the global `x`.
2024-07-22 13:53:59 -07:00
..
files [red-knot] Use vendored typeshed stubs for stdlib module resolution (#12224) 2024-07-09 09:21:52 +00:00
system [red-knot] add maybe-undefined lint rule (#12414) 2024-07-22 13:53:59 -07:00
vendored [red-knot] Use vendored typeshed stubs for stdlib module resolution (#12224) 2024-07-09 09:21:52 +00:00
file_revision.rs [red-knot]: Add a VendoredFileSystem implementation (#11863) 2024-06-18 15:43:39 +00:00
files.rs [red-knot] Add verbosity argument to CLI (#12404) 2024-07-19 11:38:24 +00:00
lib.rs [red-knot] Add basic workspace support (#12318) 2024-07-17 11:34:21 +02:00
parsed.rs [red-knot] Rename FileSystem to System (#12214) 2024-07-09 07:20:51 +00:00
program.rs [red-knot] Use a distinct type for module search paths in the module resolver (#12379) 2024-07-22 19:44:27 +00:00
source.rs [red-knot] Reload notebook on file change (#12361) 2024-07-17 12:23:48 +00:00
system.rs [red-knot] Add notebook support (#12338) 2024-07-17 08:26:33 +00:00
testing.rs [red-knot] Add more stress tests for module resolver invalidation (#12272) 2024-07-10 14:34:06 +00:00
vendored.rs [red-knot] Rename FileSystem to System (#12214) 2024-07-09 07:20:51 +00:00