ruff/crates/ruff_python_semantic/src
Dylan aa93005d8d
Control flow graph: setup (#17064)
This PR contains the scaffolding for a new control flow graph
implementation, along with its application to the `unreachable` rule. At
the moment, the implementation is a maximal over-approximation: no
control flow is modeled and all statements are counted as reachable.
With each additional statement type we support, this approximation will
improve.

So this PR just contains:
- A `ControlFlowGraph` struct and builder
- Support for printing the flow graph as a Mermaid graph
- Snapshot tests for the actual graphs
- (a very bad!) reimplementation of `unreachable` using the new structs
- Snapshot tests for `unreachable`

# Instructions for Viewing Mermaid snapshots
Unfortunately I don't know how to convince GitHub to render the Mermaid
graphs in the snapshots. However, you can view these locally in VSCode
if you install an extension that supports Mermaid graphs in Markdown,
and then add this to your `settings.json`:

```json
  "files.associations": {
"*.md.snap": "markdown",
  }
  ```
2025-04-01 05:53:42 -05:00
..
analyze Consider all TYPE_CHECKING symbols for type-checking blocks (#16669) 2025-03-13 15:37:37 +01:00
cfg Control flow graph: setup (#17064) 2025-04-01 05:53:42 -05:00
model Upgrade Rust toolchain to 1.83 (#14677) 2024-11-29 12:05:05 +00:00
binding.rs [ruff] Fix false positive on global keyword (RUF052) (#15235) 2025-01-14 08:36:40 +01:00
branches.rs Add branch detection to the semantic model (#6694) 2023-08-19 21:28:17 +00:00
context.rs
definition.rs Make setting and retrieving pydocstyle settings less tedious (#12582) 2024-07-31 10:39:33 +01:00
globals.rs Refine SemanticModel lifetime bounds (#10221) 2024-03-04 09:21:13 +01:00
imports.rs Config error only when flake8-import-conventions alias conflicts with isort.required-imports bound name (#15918) 2025-02-04 17:05:35 -06:00
lib.rs Control flow graph: setup (#17064) 2025-04-01 05:53:42 -05:00
model.rs [syntax-errors] Start detecting compile-time syntax errors (#16106) 2025-03-21 14:45:25 -04:00
nodes.rs Remove customizable reference enum names (#15647) 2025-01-21 13:46:31 -05:00
reference.rs [ruff] Avoid emitting assignment-in-assert when all references to the assigned variable are themselves inside asserts (RUF018) (#14661) 2024-11-29 13:36:59 +00:00
scope.rs Upgrade Rust toolchain to 1.83 (#14677) 2024-11-29 12:05:05 +00:00
star_import.rs Make ImportFrom level just a u32 (#11170) 2024-04-26 20:38:35 -06:00