Skip to content

Commit ef79caa

Browse files
committed
Fix default value for recurse in main function
Ensures that the 'recurse' parameter defaults to False if not provided, preventing potential issues when enumerating file paths. Also improves import ordering for consistency.
1 parent fdf2a54 commit ef79caa

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

dvuploader/cli.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import yaml
2-
import typer
3-
41
from pathlib import Path
5-
from pydantic import BaseModel
62
from typing import List, Optional
3+
4+
import typer
5+
import yaml
6+
from pydantic import BaseModel
7+
78
from dvuploader import DVUploader, File
89
from dvuploader.utils import add_directory
910

@@ -29,6 +30,7 @@ class CliInput(BaseModel):
2930

3031
app = typer.Typer()
3132

33+
3234
def _enumerate_filepaths(filepaths: List[str], recurse: bool) -> List[File]:
3335
"""
3436
Take a list of filepaths and transform it into a list of File objects, optionally recursing into each of them.
@@ -39,7 +41,7 @@ def _enumerate_filepaths(filepaths: List[str], recurse: bool) -> List[File]:
3941
4042
Returns:
4143
List[File]: A list of File objects representing the files extracted from all filepaths.
42-
44+
4345
Raises:
4446
FileNotFoundError: If a filepath does not exist.
4547
IsADirectoryError: If recurse is False and a filepath points to a directory instead of a file.
@@ -183,6 +185,9 @@ def main(
183185
if filepaths is None:
184186
filepaths = []
185187

188+
if recurse is None:
189+
recurse = False
190+
186191
_validate_inputs(
187192
filepaths=filepaths,
188193
pid=pid,
@@ -200,7 +205,10 @@ def main(
200205
api_token=api_token,
201206
dataverse_url=dataverse_url,
202207
persistent_id=pid,
203-
files=_enumerate_filepaths(filepaths=filepaths, recurse=recurse),
208+
files=_enumerate_filepaths(
209+
filepaths=filepaths,
210+
recurse=recurse,
211+
),
204212
)
205213

206214
uploader = DVUploader(files=cli_input.files)

0 commit comments

Comments
 (0)