File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments