Skip to content

Commit 2eb4c22

Browse files
committed
Lift a termination condition to a more logical point in the code
1 parent 8d3ef69 commit 2eb4c22

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

nancy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ def find_object(obj: Path) -> Optional[Union[Path, list[os.DirEntry[str]]]]:
7474
dirs.append(o)
7575
else:
7676
raise ValueError(f"'{o}' is not a file or directory")
77+
if len(dirs) == 0:
78+
return None
7779
dirents: dict[Path, os.DirEntry[str]] = {}
7880
for d in reversed(dirs):
7981
for dirent in os.scandir(d):
8082
dirents[obj / dirent.name] = dirent
81-
if len(dirs) == 0:
82-
return None
8383
return sorted(list(dirents.values()), key=lambda x: sorting_name(x.name))
8484

8585
def parse_arguments(

0 commit comments

Comments
 (0)