mirror of https://github.com/astral-sh/ruff
## Summary
Typecheck `get()`, `setdefault()`, `pop()` for `TypedDict`
```py
from typing import TypedDict
from typing_extensions import NotRequired
class Employee(TypedDict):
name: str
department: NotRequired[str]
emp = Employee(name="Alice", department="Engineering")
emp.get("name")
emp.get("departmen", "Unknown")
emp.pop("department")
emp.pop("name")
```
<img width="838" height="529" alt="Screenshot 2025-08-12 at 11 42 12"
src="https://github.com/user-attachments/assets/77ce150a-223c-4931-b914-551095d8a3a6"
/>
part of https://github.com/astral-sh/ty/issues/154
## Test Plan
Updated Markdown tests
---------
Co-authored-by: David Peter <mail@david-peter.de>
|
||
|---|---|---|
| .. | ||
| corpus | ||
| mdtest | ||
| primer | ||
| README.md | ||
README.md
Markdown files within the mdtest/ subdirectory are tests of type inference and type checking;
executed by the tests/mdtest.rs integration test.
See crates/ty_test/README.md for documentation of this test format.