mirror of https://github.com/astral-sh/ruff
## Summary This PR introduces a new `StringLike` enum which is a narrow type to indicate string-like nodes. These includes the string literals, bytes literals, and the literal parts of f-strings. The main motivation behind this is to avoid repetition of rule calling in the AST checker. We add a new `analyze::string_like` function which takes in the enum and calls all the respective rule functions which expects atleast 2 of the variants of this enum. I'm open to discarding this if others think it's not that useful at this stage as currently only 3 rules require these nodes. As suggested [here](https://github.com/astral-sh/ruff/pull/8835#discussion_r1414746934) and [here](https://github.com/astral-sh/ruff/pull/8835#discussion_r1414750204). ## Test Plan `cargo test` |
||
|---|---|---|
| .. | ||
| visitor | ||
| all.rs | ||
| call_path.rs | ||
| comparable.rs | ||
| docstrings.rs | ||
| expression.rs | ||
| hashable.rs | ||
| helpers.rs | ||
| identifier.rs | ||
| imports.rs | ||
| int.rs | ||
| lib.rs | ||
| node.rs | ||
| nodes.rs | ||
| parenthesize.rs | ||
| relocate.rs | ||
| statement_visitor.rs | ||
| stmt_if.rs | ||
| str.rs | ||
| traversal.rs | ||
| types.rs | ||
| visitor.rs | ||
| whitespace.rs | ||