ruff/crates/ruff
Charlie Marsh 627f475b91
Avoid applying PYI055 to runtime-evaluated annotations (#6457)
## Summary

The use of `|` as a union operator is not always safe, if a type
annotation is evaluated in a runtime context. For example, this code
errors at runtime:

```python
import httpretty
import requests_mock

item: type[requests_mock.Mocker | httpretty] = requests_mock.Mocker
```

However, it's fine in a `.pyi` file, with `__future__` annotations`, or
if the annotation is in a non-evaluated context, like:

```python
def func():
    item: type[requests_mock.Mocker | httpretty] = requests_mock.Mocker
```

This PR modifies the rule to avoid enforcing in those invalid,
runtime-evaluated contexts.

Closes https://github.com/astral-sh/ruff/issues/6455.
2023-08-09 16:46:41 -04:00
..
resources/test Avoid applying PYI055 to runtime-evaluated annotations (#6457) 2023-08-09 16:46:41 -04:00
src Avoid applying PYI055 to runtime-evaluated annotations (#6457) 2023-08-09 16:46:41 -04:00
Cargo.toml Bump version to 0.0.284 (#6453) 2023-08-09 13:32:33 -05:00