Commit 8ab3f95
authored
fix: Do not raise KeyError in parse_sitemap when partial options are provided (#1940)
## Description
- `ParseSitemapOptions` is declared as `TypedDict(total=False)`, so
every key is optional, but `parse_sitemap` read `emit_nested_sitemaps`,
`max_depth`, and `sitemap_retries` with direct subscripting. Any caller
passing a partial options dict (e.g. just `timeout`) via
`Sitemap.load()`, `Sitemap.parse()`, or `parse_sitemap()` hit a
`KeyError`.
- Read all options uniformly with `.get()` and the existing defaults,
collapsing the duplicated `if/else` branches.
- Add a regression test covering a partial options dict.1 parent b7c62a2 commit 8ab3f95
2 files changed
Lines changed: 15 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
451 | 445 | | |
452 | 446 | | |
453 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
270 | 278 | | |
271 | 279 | | |
272 | 280 | | |
| |||
0 commit comments