ruff/crates/ruff_linter/resources/test
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
..
fixtures Allow flake8-type-checking rules to automatically quote runtime-evaluated references (#6001) 2023-12-13 03:12:38 +00:00
package Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
project Use tool.ruff.lint in more places (#8317) 2023-10-28 18:39:38 -05:00
disallowed_rule_names.txt Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00