ruff/crates/ruff_python_semantic/src/lib.rs
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

25 lines
402 B
Rust

pub mod analyze;
mod binding;
mod branches;
pub mod cfg;
mod context;
mod definition;
mod globals;
mod imports;
mod model;
mod nodes;
mod reference;
mod scope;
mod star_import;
pub use binding::*;
pub use branches::*;
pub use context::*;
pub use definition::*;
pub use globals::*;
pub use imports::*;
pub use model::*;
pub use nodes::*;
pub use reference::*;
pub use scope::*;
pub use star_import::*;