Skip to content

Commit

Permalink
Clarify expected types
Browse files Browse the repository at this point in the history
  • Loading branch information
qubixes committed Oct 15, 2024
1 parent 6173550 commit 669dfe7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ibridges/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys
from argparse import RawTextHelpFormatter
from pathlib import Path
from typing import Optional, Union
from typing import Literal, Optional, Union

from ibridges.data_operations import download, sync, upload
from ibridges.interactive import DEFAULT_IENV_PATH, DEFAULT_IRODSA_PATH, interactive_auth
Expand Down Expand Up @@ -374,9 +374,11 @@ def _parse_remote(remote_path: Union[None, str], session: Session) -> IrodsPath:
return IrodsPath(session, remote_path[7:])
return IrodsPath(session, remote_path[6:])


def _get_metadata_path(args, ipath: IrodsPath, lpath: Union[str, Path],
mode: str) -> Union[None, str, Path]:
metadata = False if not hasattr(args, "metadata") else args.metadata
metadata: Union[Literal[False], Path, None
] = False if not hasattr(args, "metadata") else args.metadata
if ipath.dataobject_exists() and metadata is None:
raise ValueError("Supply metadata path for downloading metadata of data objects.")
if mode == "download":
Expand All @@ -385,9 +387,12 @@ def _get_metadata_path(args, ipath: IrodsPath, lpath: Union[str, Path],
default_meta_path = Path(lpath, ".ibridges_metadata.json")
else:
raise ValueError("Internal error, contact the iBridges team.")
metadata = metadata if metadata is not None else default_meta_path
metadata = None if metadata is False else metadata
return metadata
if metadata is None:
return default_meta_path
elif metadata is False:
return None
else:
return metadata


def ibridges_download():
Expand Down

0 comments on commit 669dfe7

Please sign in to comment.