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`.
34 lines
827 B
TOML
34 lines
827 B
TOML
[package]
|
|
name = "red_knot_python_semantic"
|
|
version = "0.0.0"
|
|
publish = false
|
|
authors = { workspace = true }
|
|
edition = { workspace = true }
|
|
rust-version = { workspace = true }
|
|
homepage = { workspace = true }
|
|
documentation = { workspace = true }
|
|
repository = { workspace = true }
|
|
license = { workspace = true }
|
|
|
|
[dependencies]
|
|
red_knot_module_resolver = { workspace = true }
|
|
ruff_db = { workspace = true }
|
|
ruff_index = { workspace = true }
|
|
ruff_python_ast = { workspace = true }
|
|
ruff_text_size = { workspace = true }
|
|
|
|
bitflags = { workspace = true }
|
|
ordermap = { workspace = true }
|
|
salsa = { workspace = true }
|
|
tracing = { workspace = true }
|
|
rustc-hash = { workspace = true }
|
|
hashbrown = { workspace = true }
|
|
|
|
[dev-dependencies]
|
|
anyhow = { workspace = true }
|
|
ruff_python_parser = { workspace = true }
|
|
|
|
[lints]
|
|
workspace = true
|
|
|