ruff/crates/ruff_python_semantic/src
Charlie Marsh 932c9a4789
Extend PEP 604 rewrites to support some quoted annotations (#5725)
## Summary

Python doesn't allow `"Foo" | None` if the annotation will be evaluated
at runtime (see the comments in the PR, or the semantic model
documentation for more on what this means and when it is true), but it
_does_ allow it if the annotation is typing-only.

This, for example, is invalid, as Python will evaluate `"Foo" | None` at
runtime in order to
populate the function's `__annotations__`:

```python
def f(x: "Foo" | None): ...
```

This, however, is valid:

```python
def f():
    x: "Foo" | None
```

As is this:

```python
from __future__ import annotations

def f(x: "Foo" | None): ...
```

Closes #5706.
2023-07-13 07:34:04 -04:00
..
analyze Extend PEP 604 rewrites to support some quoted annotations (#5725) 2023-07-13 07:34:04 -04:00
binding.rs Enable attribute lookups via semantic model (#5536) 2023-07-05 15:19:14 -04:00
context.rs Remove separate `ReferenceContext` enum (#4631) 2023-05-24 15:12:38 +00:00
definition.rs Run `rustfmt` on nightly to clean up erroneous comments (#5106) 2023-06-15 00:19:05 +00:00
globals.rs Make some of `ruff_python_semantic` `pub(crate)` (#5093) 2023-06-14 17:49:37 +00:00
lib.rs Move `StarImport` to its own module (#5186) 2023-06-20 13:12:46 -04:00
model.rs Differentiate between runtime and typing-time annotations (#5575) 2023-07-07 00:21:44 -04:00
node.rs Make some of `ruff_python_semantic` `pub(crate)` (#5093) 2023-06-14 17:49:37 +00:00
reference.rs Make some of `ruff_python_semantic` `pub(crate)` (#5093) 2023-06-14 17:49:37 +00:00
scope.rs Run shadowed-variable analyses in deferred handlers (#5181) 2023-06-29 00:08:18 +00:00
star_import.rs Move `StarImport` to its own module (#5186) 2023-06-20 13:12:46 -04:00