Welp, found an example where ty, mypy, and pyright disagree, and where none of them appear to be quite correct?

```python
from typing import Any, Optional, cast, reveal_type
class Config:
values: dict[str, Any] = {}

def get[T](self, key: str) -> Optional[T]:
return cast(T, self.values[key])

config = Config()
foo = config.get("foo")
reveal_type(foo)

bar: dict[str, str] = config.get(key="bar") or {}
reveal_type(bar)
```

0

If you have a fediverse account, you can quote this note from your own instance. Search https://wandering.shop/users/xgranade/statuses/115947005404787488 on your instance and quote it. (Note that quoting is not supported in Mastodon.)