Skip to content

Commit 9463861

Browse files
authored
[evaluation] fix: Resolve bandit violations (#37454)
* fix: Use ast.literal_eval to parse string to list * style: Run black
1 parent b7ace86 commit 9463861

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_common/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import numpy as np
1212

1313

14-
1514
def get_harm_severity_level(harm_score: int) -> str:
1615
"""Generate harm severity level based on harm score.
1716

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_meteor/_meteor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def __init__(self, alpha: float = 0.9, beta: float = 3.0, gamma: float = 0.5):
1414
self._gamma = gamma
1515

1616
try:
17-
nltk.find('corpora/wordnet.zip')
17+
nltk.find("corpora/wordnet.zip")
1818
except LookupError:
19-
nltk.download('wordnet')
19+
nltk.download("wordnet")
2020

2121
async def __call__(self, *, ground_truth: str, answer: str, **kwargs):
2222
reference_tokens = nltk_tokenize(ground_truth)

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/simulator/_conversation/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525

2626
class ConversationRole(Enum):
2727
"""Role in a chatbot conversation"""
28+
2829
USER = "user"
2930
ASSISTANT = "assistant"

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/simulator/_model_tools/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# ---------------------------------------------------------
44
# pylint: skip-file
5+
import ast
56
import asyncio
67
import copy
78
import logging
@@ -234,7 +235,7 @@ def __init__(
234235
stop = []
235236
# Else if stop sequence is given as a string (Ex: "["\n", "<im_end>"]"), convert
236237
elif type(stop) is str and stop.startswith("[") and stop.endswith("]"):
237-
stop = eval(stop)
238+
stop = ast.literal_eval(stop)
238239
elif type(stop) is str:
239240
stop = [stop]
240241
self.stop: List = stop # type: ignore[assignment]

0 commit comments

Comments
 (0)