[red-knot] Infer Todo, not Unknown, for PEP-604 unions in annotations (#13908)

This commit is contained in:
Alex Waygood
2024-10-25 19:21:31 +01:00
committed by GitHub
parent 085a43a262
commit 5eb87aa56e
3 changed files with 32 additions and 5 deletions

View File

@@ -22,3 +22,13 @@ x: int = "foo" # error: [invalid-assignment] "Object of type `Literal["foo"]` i
x: int
x = "foo" # error: [invalid-assignment] "Object of type `Literal["foo"]` is not assignable to `int`"
```
## PEP-604 annotations not yet supported
```py
def f() -> str | None:
return None
# TODO: should be `str | None` (but Todo is better than `Unknown`)
reveal_type(f()) # revealed: @Todo
```