ruff/crates/ruff_python_semantic/src
Charlie Marsh 10ace88e9a
Track conditional deletions in the semantic model (#10415)
## Summary

Given `del X`, we'll typically add a `BindingKind::Deletion` to `X` to
shadow the current binding. However, if the deletion is inside of a
conditional operation, we _won't_, as in:

```python
def f():
    global X

    if X > 0:
        del X
```

We will, however, track it as a reference to the binding. This PR adds
the expression context to those resolved references, so that we can
detect that the `X` in `global X` was "assigned to".

Closes https://github.com/astral-sh/ruff/issues/10397.
2024-03-14 20:45:46 -04:00
..
analyze refactor: Use QualifiedName for Imported::call_path (#10214) 2024-03-06 09:55:59 +01:00
binding.rs Track conditional deletions in the semantic model (#10415) 2024-03-14 20:45:46 -04:00
branches.rs Add branch detection to the semantic model (#6694) 2023-08-19 21:28:17 +00:00
context.rs Remove separate ReferenceContext enum (#4631) 2023-05-24 15:12:38 +00:00
definition.rs Refine SemanticModel lifetime bounds (#10221) 2024-03-04 09:21:13 +01:00
globals.rs Refine SemanticModel lifetime bounds (#10221) 2024-03-04 09:21:13 +01:00
lib.rs Use a single node hierarchy to track statements and expressions (#6709) 2023-08-21 21:32:57 -04:00
model.rs Track conditional deletions in the semantic model (#10415) 2024-03-14 20:45:46 -04:00
nodes.rs Move {AnyNodeRef, AstNode} to ruff_python_ast crate root (#8030) 2023-10-18 00:01:18 +00:00
reference.rs Track conditional deletions in the semantic model (#10415) 2024-03-14 20:45:46 -04:00
scope.rs Refine SemanticModel lifetime bounds (#10221) 2024-03-04 09:21:13 +01:00
star_import.rs Move StarImport to its own module (#5186) 2023-06-20 13:12:46 -04:00