Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
frankqianms committed Feb 26, 2025
1 parent 202f2e3 commit 78a7038
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def get_used_citations(
citations: List[Union[ClientCitation, Dict[str, Any]]] The list of citations to search for.
Supports both ClientCitation objects and dictionary representations.
Returns:
Optional[List[Union[ClientCitation, Dict[str, Any]]]]: The list of citations used in the text.
Optional[List[Union[ClientCitation, Dict[str, Any]]]]: The list of citations used in the
text.
"""
regex = r"\[(\d+)\]"
matches = re.findall(regex, text)
Expand All @@ -39,8 +40,8 @@ def get_used_citations(
if isinstance(citation, ClientCitation) and str(citation.position) == match:
used_citations.append(citation)
break
elif isinstance(citation, dict) and str(citation["position"]) == match:
if isinstance(citation, dict) and str(citation["position"]) == match:
used_citations.append(citation)
break

return used_citations
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ def test_get_used_citations_dict(self):
}
}
]

text = "hello [2] world [3]"
result = get_used_citations(text, citations)

assert result is not None
self.assertEqual(len(result), 2)
self.assertEqual(result, [citations[1], citations[2]])

# Test with empty matches
text_no_citations = "hello world with no citations"
result_empty = get_used_citations(text_no_citations, citations)
self.assertIsNone(result_empty)

# Test with duplicate citations
text_duplicate = "hello [1] world [1] again"
result_duplicate = get_used_citations(text_duplicate, citations)
Expand Down

0 comments on commit 78a7038

Please sign in to comment.