From 474409cebcba97de141c607f5a38d7d9ffc6daae Mon Sep 17 00:00:00 2001 From: Yue Shuai <48269801+yueshuaing@users.noreply.github.com> Date: Tue, 20 Aug 2024 21:40:33 -0700 Subject: [PATCH] initialize _cards, otherwise any cards saved in _cards are preserved in the next call --- projectcard/io.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projectcard/io.py b/projectcard/io.py index 40decd8..23c2e3c 100644 --- a/projectcard/io.py +++ b/projectcard/io.py @@ -186,7 +186,7 @@ def read_cards( filepath: Union[Collection[str], str], filter_tags: Collection[str] = [], recursive: bool = False, - _cards: Mapping[str, ProjectCard] = {}, + _cards: Mapping[str, ProjectCard] = None, ) -> Mapping[str, ProjectCard]: """Reads collection of project card files by inferring the file type. @@ -204,6 +204,9 @@ def read_cards( """ CardLogger.debug(f"Reading cards from {filepath}.") + if _cards is None: + _cards = {} + filter_tags = list(map(str.lower, filter_tags)) if isinstance(filepath, list) or not os.path.isfile(filepath): _card_paths = _get_cardpath_list(