Commit e621929
fix: pass --setting-sources for empty list to disable filesystem settings (#822)
## Summary
`setting_sources=[]` was treated as falsy and silently dropped, so it
behaved the same as `None`: the spawned CLI loaded its default
user/project/local setting sources. The TypeScript SDK already
distinguishes `undefined` (CLI defaults) from `[]` (disable all) by
checking `!== undefined` and using equals-syntax so the empty value
survives argv parsing.
This change applies the same pattern: check `is not None` and pass
`--setting-sources=` (single argv element) so an empty list reaches the
CLI parser as "disable all sources."
## Tests
- `test_build_command_setting_sources_omitted_when_not_provided`: now
uses `startswith` so it can't pass vacuously against the equals form
- `test_build_command_setting_sources_empty_list_disables_all`:
rewritten; previously asserted the flag was omitted for `[]`
- `test_build_command_setting_sources_included_when_provided`: updated
for single-element `--setting-sources=user,project`
```
3 passed, 56 deselected
```
Companion docs change: anthropics/claude-code-docs branch
`claude/clarify-cost-tracking-docs-3ILH3`.
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ebc06f2 commit e621929
3 files changed
Lines changed: 44 additions & 16 deletions
File tree
- examples
- src/claude_agent_sdk/_internal/transport
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
59 | 88 | | |
60 | 89 | | |
61 | 90 | | |
| |||
66 | 95 | | |
67 | 96 | | |
68 | 97 | | |
69 | | - | |
| 98 | + | |
70 | 99 | | |
71 | 100 | | |
72 | 101 | | |
| |||
139 | 168 | | |
140 | 169 | | |
141 | 170 | | |
| 171 | + | |
142 | 172 | | |
143 | 173 | | |
144 | 174 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
284 | | - | |
| 283 | + | |
| 284 | + | |
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
437 | | - | |
| 437 | + | |
438 | 438 | | |
439 | | - | |
440 | | - | |
| 439 | + | |
| 440 | + | |
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
446 | | - | |
| 446 | + | |
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
456 | | - | |
457 | | - | |
| 455 | + | |
458 | 456 | | |
459 | 457 | | |
460 | 458 | | |
| |||
0 commit comments