Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit cb577d2

Browse files
committed
Fix bandit.
1 parent 99d712d commit cb577d2

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/codegate/muxing/ollama_mappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def ollama_generate_from_openai(
215215

216216
def _gen_tool_call_id():
217217
letter_bytes = string.ascii_lowercase + string.digits
218-
b = [letter_bytes[random.randint(0, len(letter_bytes) - 1)] for _ in range(8)]
218+
b = [letter_bytes[random.randint(0, len(letter_bytes) - 1)] for _ in range(8)] # nosec
219219
return "call_" + "".join(b).lower()
220220

221221

src/codegate/pipeline/pii/pii.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ async def process_chunk( # noqa: C901
320320
end_idx = text.find(self.marker_end, start_idx + 1)
321321
if end_idx == -1:
322322
# Incomplete marker, buffer the rest only if it can be a UUID
323-
if start_idx + 1 < len(content) and not can_be_uuid(content[start_idx + 1 :]):
323+
if start_idx + 1 < len(text) and not can_be_uuid(text[start_idx + 1 :]):
324324
# the buffer can't be a UUID, so we can't process it, just return
325-
result.append(content[current_pos:])
325+
result.append(text[current_pos:])
326326
else:
327327
# this can still be a UUID
328-
context.prefix_buffer = content[current_pos:]
328+
context.prefix_buffer = text[current_pos:]
329329
break
330330

331331
# Add text before marker

src/codegate/types/anthropic/_generators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,5 @@ async def message_wrapper(lines):
155155
raise ValueError(f"anthropic: unexpected event type '{event_type}'")
156156

157157
# The following should always hold when we get here
158-
assert event_type == "message_stop" or event_type == "error"
158+
assert event_type == "message_stop" or event_type == "error" # nosec
159159
return

tests/pipeline/pii/test_pi.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,27 +132,27 @@ async def test_process_chunk_with_uuid(self, unredaction_step):
132132

133133
@pytest.mark.asyncio
134134
async def test_detect_not_an_uuid(self, unredaction_step):
135-
chunk1 = ModelResponse(
135+
chunk1 = StreamingChatCompletion(
136136
id="test",
137137
choices=[
138-
StreamingChoices(
138+
ChoiceDelta(
139139
finish_reason=None,
140140
index=0,
141-
delta=Delta(content="#"),
141+
delta=MessageDelta(content="#"),
142142
logprobs=None,
143143
)
144144
],
145145
created=1234567890,
146146
model="test-model",
147147
object="chat.completion.chunk",
148148
)
149-
chunk2 = ModelResponse(
149+
chunk2 = StreamingChatCompletion(
150150
id="test",
151151
choices=[
152-
StreamingChoices(
152+
ChoiceDelta(
153153
finish_reason=None,
154154
index=0,
155-
delta=Delta(content=" filepath"),
155+
delta=MessageDelta(content=" filepath"),
156156
logprobs=None,
157157
)
158158
],

0 commit comments

Comments
 (0)