Commit 964ba4e
authored
Fix TypeError in by_name() when name is not found (#83)
* Fix TypeError in by_name() when name is not found
When using `match="equals"` (the default), `by_name()` would return
`None` from `dict.get(name, None)` if the name wasn't found in the
lookup cache. This caused `len(matches)` on line 51 to raise:
TypeError: object of type 'NoneType' has no len()
This fix changes the default value from `None` to `[]` (empty list),
making it consistent with the `match="contains"` branch which already
initializes `matches = []`.
* fix: move empty result check up before checking if user asked for all
* add(test): tests for consistent None return for by_name method1 parent c13bab0 commit 964ba4e
File tree
2 files changed
+19
-5
lines changed- pipeline
- src/additional_methods
- tests
2 files changed
+19
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | | - | |
52 | | - | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
0 commit comments