Skip to content

Commit

Permalink
fix: add type ignore to fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
frankqianms committed Feb 26, 2025
1 parent 78a7038 commit 78e1c9f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions python/packages/ai/teams/ai/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async def _on_say_command(
content_text = content if not citations else format_citations_response(content)

# If there are citations, filter out the citations unused in content.
referenced_citations = get_used_citations(content_text, citations)
referenced_citations = get_used_citations(content_text, citations) # type: ignore
channel_data: Dict[str, Any] = {}

if is_teams_channel:
Expand All @@ -331,7 +331,9 @@ async def _on_say_command(
channel_data=channel_data,
entities=[
AIEntity(
citation=(list(referenced_citations) if referenced_citations else []),
citation=(
list(referenced_citations) if referenced_citations else []# type: ignore
),
additional_type=["AIGeneratedContent"],
),
],
Expand Down
4 changes: 2 additions & 2 deletions python/packages/ai/teams/streaming/streaming_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ async def send_activity(self, activity: Activity) -> None:

# If there are citations, filter out the citations unused in content.
if self._citations and len(self._citations) > 0 and self._ended is False:
curr_citations = get_used_citations(self._message, self._citations)
curr_citations = get_used_citations(self._message, self._citations) # type: ignore
activity.entities.append(
AIEntity(
additional_type=[],
citation=curr_citations if curr_citations else [],
citation=curr_citations if curr_citations else [], # type: ignore
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_used_citations(
if not matches:
return None

used_citations = []
used_citations: List[Union[ClientCitation, Dict[str, Any]]] = [] # Explicitly type this
processed_matches = []
for match in matches:
if match in processed_matches:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_get_used_citations(self):
),
]
text = "hello [1] world"
result = get_used_citations(text, citations)
result = get_used_citations(text, citations) # type: ignore
assert result is not None
self.assertEqual(len(result), 1)

Expand All @@ -48,7 +48,7 @@ def test_get_used_citations_longer(self):
),
]
text = "hello [1] world [3]"
result = get_used_citations(text, citations)
result = get_used_citations(text, citations) # type: ignore
if result is not None:
self.assertEqual(len(result), 2)
else:
Expand Down Expand Up @@ -81,20 +81,20 @@ def test_get_used_citations_dict(self):
]

text = "hello [2] world [3]"
result = get_used_citations(text, citations)
result = get_used_citations(text, citations) # type: ignore

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)
result_empty = get_used_citations(text_no_citations, citations) # type: ignore
self.assertIsNone(result_empty)

# Test with duplicate citations
text_duplicate = "hello [1] world [1] again"
result_duplicate = get_used_citations(text_duplicate, citations)
result_duplicate = get_used_citations(text_duplicate, citations) # type: ignore
assert result_duplicate is not None
self.assertEqual(len(result_duplicate), 1)
self.assertEqual(result_duplicate, [citations[0]])

0 comments on commit 78e1c9f

Please sign in to comment.