Skip to content

Commit 87efef9

Browse files
correct find_common_tags code sample
1 parent ad09525 commit 87efef9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

codeflash/cli_cmds/cmd_init.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,13 +1227,16 @@ def enter_api_key_and_save_to_rc() -> None:
12271227

12281228

12291229
def create_find_common_tags_file(args: Namespace, file_name: str) -> Path:
1230-
find_common_tags_content = """def find_common_tags(articles: list[dict[str, list[str]]]) -> set[str]:
1230+
find_common_tags_content = """from __future__ import annotations
1231+
1232+
1233+
def find_common_tags(articles: list[dict[str, list[str]]]) -> set[str]:
12311234
if not articles:
12321235
return set()
12331236
1234-
common_tags = articles[0]["tags"]
1237+
common_tags = articles[0].get("tags", [])
12351238
for article in articles[1:]:
1236-
common_tags = [tag for tag in common_tags if tag in article["tags"]]
1239+
common_tags = [tag for tag in common_tags if tag in article.get("tags", [])]
12371240
return set(common_tags)
12381241
"""
12391242

0 commit comments

Comments
 (0)