Commit 8ad874b
authored
Change `NeedPartData.backlinks` from `dict[str, list[str]]` to
`dict[str, list[NeedLink]]`, aligning it with how `NeedItem` already
stores its backlinks internally.
Previously, part backlinks were stored as raw strings and converted to
`NeedLink` on read (e.g. in `NeedPartItem.get_backlinks(as_str=False)`).
Now they are stored as `NeedLink` from the start, avoiding redundant
re-parsing and making the internal representation consistent across
needs and parts.
**Changes:**
- `NeedPartData.backlinks` type: `dict[str, list[str]]` → `dict[str,
list[NeedLink]]`
- `resolve_links()`: append `NeedLink(id=key)` instead of raw `str` to
part backlinks
- `_recompute()`, `NeedPartItem.__init__`: serialize via
`to_filter_string()` for dict-like access and JSON output (unchanged
external behavior)
- `NeedPartItem.get_backlinks`/`iter_backlinks_items`: return stored
`NeedLink` directly instead of re-parsing from strings
- `_validate_part`: validate `NeedLink` instances instead of `str`
No change in external behavior — dict-like access
(`item["links_back"]`), JSON serialization, and all public APIs continue
to return the same values.
1 parent dce9f99 commit 8ad874b
3 files changed
Lines changed: 15 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
482 | | - | |
| 482 | + | |
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
| 186 | + | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
427 | 431 | | |
428 | 432 | | |
429 | 433 | | |
| |||
916 | 920 | | |
917 | 921 | | |
918 | 922 | | |
919 | | - | |
| 923 | + | |
920 | 924 | | |
921 | 925 | | |
922 | 926 | | |
923 | | - | |
| 927 | + | |
924 | 928 | | |
925 | 929 | | |
926 | 930 | | |
| |||
1020 | 1024 | | |
1021 | 1025 | | |
1022 | 1026 | | |
1023 | | - | |
| 1027 | + | |
1024 | 1028 | | |
1025 | 1029 | | |
1026 | 1030 | | |
| |||
1270 | 1274 | | |
1271 | 1275 | | |
1272 | 1276 | | |
1273 | | - | |
| 1277 | + | |
1274 | 1278 | | |
1275 | 1279 | | |
1276 | 1280 | | |
| |||
1295 | 1299 | | |
1296 | 1300 | | |
1297 | 1301 | | |
1298 | | - | |
| 1302 | + | |
1299 | 1303 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
370 | 372 | | |
371 | 373 | | |
372 | 374 | | |
| |||
0 commit comments