ruff/crates
Dhruv Manilawala 180920fdd9
Make semantic model aware of docstring (#9960)
## 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>
2024-02-13 04:26:08 +00:00
..
ruff unused_imports/F401: Explain when imports are preserved (#9963) 2024-02-12 19:07:20 -05:00
ruff_benchmark Run doctests as part of CI pipeline (#9939) 2024-02-12 10:18:58 +01:00
ruff_cache Make all dependencies workspace dependencies (#9333) 2024-01-02 13:41:59 +00:00
ruff_dev Allow arbitrary configuration options to be overridden via the CLI (#9599) 2024-02-09 21:56:37 +00:00
ruff_diagnostics Run doctests as part of CI pipeline (#9939) 2024-02-12 10:18:58 +01:00
ruff_formatter Use Rust 1.76 (#9897) 2024-02-08 18:20:08 +00:00
ruff_index Run doctests as part of CI pipeline (#9939) 2024-02-12 10:18:58 +01:00
ruff_linter Make semantic model aware of docstring (#9960) 2024-02-13 04:26:08 +00:00
ruff_macros Run doctests as part of CI pipeline (#9939) 2024-02-12 10:18:58 +01:00
ruff_notebook Run doctests as part of CI pipeline (#9939) 2024-02-12 10:18:58 +01:00
ruff_python_ast [perflint] Catch a wider range of mutations in PERF101 (#9955) 2024-02-12 12:17:55 -05:00
ruff_python_codegen Use non-parenthesized range for DebugText (#9953) 2024-02-12 23:00:02 +05:30
ruff_python_formatter Disable top-level docstring formatting for notebooks (#9957) 2024-02-12 18:14:02 +00:00
ruff_python_index Run doctests as part of CI pipeline (#9939) 2024-02-12 10:18:58 +01:00
ruff_python_literal Run doctests as part of CI pipeline (#9939) 2024-02-12 10:18:58 +01:00
ruff_python_parser Use non-parenthesized range for DebugText (#9953) 2024-02-12 23:00:02 +05:30
ruff_python_resolver Run doctests as part of CI pipeline (#9939) 2024-02-12 10:18:58 +01:00
ruff_python_semantic Make semantic model aware of docstring (#9960) 2024-02-13 04:26:08 +00:00
ruff_python_stdlib Slight speed-up for lowercase and uppercase identifier checks (#9798) 2024-02-03 14:40:41 +00:00
ruff_python_trivia Add fast-path for comment detection (#9808) 2024-02-05 11:00:18 -05:00
ruff_shrinking Bump version to v0.2.1 (#9843) 2024-02-05 15:31:05 -05:00
ruff_source_file Fix blank-line docstring rules for module-level docstrings (#9878) 2024-02-07 16:48:28 -05:00
ruff_text_size Range formatting: Fix invalid syntax after parenthesizing expression (#9751) 2024-02-02 17:56:25 +01:00
ruff_wasm Run doctests as part of CI pipeline (#9939) 2024-02-12 10:18:58 +01:00
ruff_workspace Stabilize quote-style preserve (#9922) 2024-02-12 09:30:07 +00:00