Files
David Peter 429d86ea49 [ty] Exclude init=False dataclass fields from __replace__ (#30850)
## Summary

Passing a dataclass field with `init=False` to `copy.replace` raises a
`TypeError` at runtime. ty now excludes these fields from the signature
of the synthesized `__replace__` method.

```py
from copy import replace
from dataclasses import dataclass, field

@dataclass
class User:
    name: str
    id: int = field(init=False, default=0)

user = User(name="Alice")
replace(user, name="Bob")  # ok
replace(user, id=42)  # ty now reports an unknown argument here
```

This also applies to attrs classes, Pydantic dataclasses and other
classes that use `dataclass_transform`.
2026-11-23 22:03:47 +01:00
..