mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 21:25:08 +00:00

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", } ```
39 lines
1.1 KiB
TOML
39 lines
1.1 KiB
TOML
[package]
|
|
name = "ruff_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]
|
|
ruff_cache = { workspace = true }
|
|
ruff_index = { workspace = true }
|
|
ruff_macros = { workspace = true }
|
|
ruff_python_ast = { workspace = true }
|
|
ruff_python_parser = { workspace = true }
|
|
ruff_python_stdlib = { workspace = true }
|
|
ruff_text_size = { workspace = true }
|
|
|
|
bitflags = { workspace = true }
|
|
is-macro = { workspace = true }
|
|
rustc-hash = { workspace = true }
|
|
schemars = { workspace = true, optional = true }
|
|
serde = { workspace = true, optional = true }
|
|
smallvec = { workspace = true }
|
|
|
|
[dev-dependencies]
|
|
insta = { workspace = true, features = ["filters", "json", "redactions"] }
|
|
test-case = { workspace = true }
|
|
ruff_python_parser = { workspace = true }
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[package.metadata.cargo-shear]
|
|
# Used via `CacheKey` macro expansion.
|
|
ignored = ["ruff_cache"]
|