mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-11 19:56:03 +00:00
fix(mypy): resolve union type and list annotation errors
- batches.py: Fix bytes/memoryview union type narrowing issue - encoder_utils.py: Add type annotation for masks_list 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d612924f5b
commit
a40af5b91b
2 changed files with 5 additions and 6 deletions
|
|
@ -141,7 +141,7 @@ def build_encoder_attention_mask(
|
|||
"""
|
||||
Build vision encoder attention mask that omits padding tokens.
|
||||
"""
|
||||
masks_list = []
|
||||
masks_list: list[torch.Tensor] = []
|
||||
for arx in ar:
|
||||
mask_i = torch.ones((num_chunks, x.shape[2], 1), dtype=x.dtype)
|
||||
mask_i[: arx[0] * arx[1], :ntok] = 0
|
||||
|
|
|
|||
|
|
@ -358,11 +358,10 @@ class ReferenceBatchesImpl(Batches):
|
|||
|
||||
# TODO(SECURITY): do something about large files
|
||||
file_content_response = await self.files_api.openai_retrieve_file_content(batch.input_file_id)
|
||||
# Handle both bytes and memoryview types
|
||||
body = file_content_response.body
|
||||
if isinstance(body, memoryview):
|
||||
body = bytes(body)
|
||||
file_content = body.decode("utf-8")
|
||||
# Handle both bytes and memoryview types - convert to bytes unconditionally
|
||||
# (bytes(x) returns x if already bytes, creates new bytes from memoryview otherwise)
|
||||
body_bytes = bytes(file_content_response.body)
|
||||
file_content = body_bytes.decode("utf-8")
|
||||
for line_num, line in enumerate(file_content.strip().split("\n"), 1):
|
||||
if line.strip(): # skip empty lines
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue