mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
![]() ## Summary This PR introduces a new semantic model flag `DOCSTRING` which suggests that the model is currently in a module / class / function docstring. This is the first step in eliminating the docstring detection state machine which is prone to bugs as stated in #7595. ## Test Plan ~TODO: Is there a way to add a test case for this?~ I tested this using the following code snippet and adding a print statement in the `string_like` analyzer to print if we're currently in a docstring or not. <details><summary>Test code snippet:</summary> <p> ```python "Docstring" ", still a docstring" "Not a docstring" def foo(): "Docstring" "Not a docstring" if foo: "Not a docstring" pass class Foo: "Docstring" "Not a docstring" foo: int "Unofficial variable docstring" def method(): "Docstring" "Not a docstring" pass def bar(): "Not a docstring".strip() def baz(): _something_else = 1 """Not a docstring""" ``` </p> </details> |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |