[chore] Add no-getattr rule; refine no-dataclasses rule (#29871)
This commit is contained in:
@@ -7,12 +7,12 @@ paths:
|
||||
|
||||
Define data containers as `msgspec.Struct`. Do not add new
|
||||
`dataclasses.dataclass` (or `attrs`) — they weaken strict type checking and
|
||||
don't map onto Rust structs for the planned Rust migration.
|
||||
don't translate cleanly for multi-language support (e.g. the planned Rust migration).
|
||||
|
||||
```python
|
||||
import msgspec
|
||||
|
||||
class LoadSnapshot(msgspec.Struct): # frozen=, kw_only=, omit_defaults= as needed
|
||||
class LoadSnapshot(msgspec.Struct): # prefer frozen= and omit_defaults=; kw_only= as needed
|
||||
dp_rank: int = 0
|
||||
tokens: list[int] = [] # mutable defaults are safe
|
||||
```
|
||||
@@ -21,4 +21,3 @@ class LoadSnapshot(msgspec.Struct): # frozen=, kw_only=, omit_defaults= as nee
|
||||
`python/sglang/srt/managers/load_snapshot.py`.
|
||||
- New code only. Existing `@dataclass` is grandfathered — migrate opportunistically
|
||||
while editing the file, not in drive-by sweeps.
|
||||
- If a third-party API forces `@dataclass`, keep it at that boundary only.
|
||||
|
||||
Reference in New Issue
Block a user