ruff/crates/ruff_workspace/src
Charlie Marsh 1a65e544c5
Allow flake8-type-checking rules to automatically quote runtime-evaluated references (#6001)
## Summary

This allows us to fix usages like:

```python
from pandas import DataFrame

def baz() -> DataFrame:
    ...
```

By quoting the `DataFrame` in `-> DataFrame`. Without quotes, moving
`from pandas import DataFrame` into an `if TYPE_CHECKING:` block will
fail at runtime, since Python tries to evaluate the annotation to add it
to the function's `__annotations__`.

Unfortunately, this does require us to split our "annotation kind" flags
into three categories, rather than two:

- `typing-only`: The annotation is only evaluated at type-checking-time.
- `runtime-evaluated`: Python will evaluate the annotation at runtime
(like above) -- but we're willing to quote it.
- `runtime-required`: Python will evaluate the annotation at runtime
(like above), and some library (like Pydantic) needs it to be available
at runtime, so we _can't_ quote it.

This functionality is gated behind a setting
(`flake8-type-checking.quote-annotations`).

Closes https://github.com/astral-sh/ruff/issues/5559.
2023-12-13 03:12:38 +00:00
..
configuration.rs Add "preserve" quote-style to mimic Black's skip-string-normalization (#8822) 2023-12-07 23:59:22 +00:00
lib.rs Add most formatter options to ruff.toml / pyproject.toml (#7566) 2023-09-22 15:47:57 +00:00
options.rs Allow flake8-type-checking rules to automatically quote runtime-evaluated references (#6001) 2023-12-13 03:12:38 +00:00
options_base.rs Remove repeated and erroneous scoped settings headers in docs (#8670) 2023-11-14 05:44:30 +00:00
pyproject.rs Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
resolver.rs Stop at the first resolved parent configuration (#8864) 2023-11-29 04:21:07 +00:00
settings.rs Change line-ending default to auto (#8057) 2023-10-20 00:13:11 +01:00