Skip to content

Commit b545268

Browse files
committed
Use 'None' as a default for the 'result' parameter instead
1 parent 66ecf4e commit b545268

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/murfey/server/api/session_shared.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,10 @@ def _recursive_search(
148148
search_string: str,
149149
partial_match: bool = True,
150150
max_depth: int = 1,
151-
result: dict[str, Path] = {},
151+
result: dict[str, Path] | None = None,
152152
):
153-
# Start a new dictionary object if none were provided
154-
# This if-block prevents in-place memory modification on subsequent loops
155-
if not result:
153+
# If no dictionary was passed in, create a new dictionary
154+
if result is None:
156155
result = {}
157156
# Stop recursing for this route once max depth hits 0
158157
if max_depth == 0:
@@ -167,7 +166,8 @@ def _recursive_search(
167166
if partial_match
168167
else search_string == entry.name
169168
):
170-
result[entry.name] = Path(entry.path)
169+
if result is not None: # MyPy needs this 'is not None' check
170+
result[entry.name] = Path(entry.path)
171171
else:
172172
# Continue searching down this route until max depth is reached
173173
result = _recursive_search(

0 commit comments

Comments
 (0)