From 7c8263581852e3e5eb1b1574b4f182c43eb06c53 Mon Sep 17 00:00:00 2001 From: Akio Taniguchi Date: Thu, 16 Nov 2023 19:50:09 +0000 Subject: [PATCH] #9 Update return type of list command --- deshima_rawdata/cli.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/deshima_rawdata/cli.py b/deshima_rawdata/cli.py index a8f68da..932f1e0 100644 --- a/deshima_rawdata/cli.py +++ b/deshima_rawdata/cli.py @@ -4,6 +4,7 @@ # standard library import tarfile from pathlib import Path +from typing import Any, Literal, overload # dependencies @@ -79,14 +80,24 @@ def download( return data_path.with_name(dir_name) -def list(format: str = DEFAULT_LIST_FORMAT) -> str: +@overload +def list(format: Literal["csv", "json", "markdown"]) -> str: + ... + + +@overload +def list(format: Literal["dict"]) -> dict[str, str]: + ... + + +def list(format: str = DEFAULT_LIST_FORMAT) -> Any: """List DESHIMA raw datasets available in the package. Args: format: Format of the list that can be output by pandas. Returns: - String of the list with given format. + The list of DESHIMA raw datasets with given format. """ return getattr(DATA_LIST, f"to_{format}")()