Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces python-magic with built-in mimetypes #105

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions assistants/prospector-assistant/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions libraries/python/assistant-drive/assistant_drive/drive.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import io
import json
import logging
import mimetypes
import os
import pathlib
from contextlib import contextmanager
from datetime import datetime
from shutil import rmtree
from typing import Any, BinaryIO, ContextManager, Iterator, TypeVar

import magic
from context import Context
from pydantic import BaseModel, Field

# from pydantic_settings import BaseSettings

logger = logging.getLogger(__name__)
mime = magic.Magic(mime=True)


class DriveConfig(BaseModel):
Expand Down Expand Up @@ -59,8 +58,8 @@ def __str__(self) -> str:

@staticmethod
def from_bytes(content: BinaryIO, filename: str, dir: str | None = None) -> "FileMetadata":
content_type = mime.from_buffer(content.read())
content.seek(0)
mime_type, _ = mimetypes.guess_type(filename)
content_type = mime_type or "application/octet-stream"
size = len(content.read())
return FileMetadata(filename=filename, dir=dir, content_type=content_type, size=size)

Expand Down
2 changes: 1 addition & 1 deletion libraries/python/assistant-drive/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies = [
"context>=0.1.0",
"pydantic>=2.6.1",
"pydantic-settings>=2.5.2",
"python-magic>=0.4.27",
# "python-magic>=0.4.27",
# "python-magic-bin>=0.4.14",
]

Expand Down
11 changes: 0 additions & 11 deletions libraries/python/assistant-drive/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.