Skip to content

Commit cdb30ef

Browse files
committed
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 = []`.
1 parent c13bab0 commit cdb30ef

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

pipeline/src/additional_methods/by_name.py.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
else:
3939
cls._instance_lookup[key] = [instance]
4040
if match == "equals":
41-
matches = cls._instance_lookup.get(name, None)
41+
matches = cls._instance_lookup.get(name, [])
4242
elif match == "contains":
4343
matches = []
4444
for key, instances in cls._instance_lookup.items():

0 commit comments

Comments
 (0)