Linting/Formatting of core folder #102
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors and improves the core media processing utilities for the MLX OpenAI server, focusing on better type safety, code clarity, and robust resource management. The changes modernize the codebase by adopting newer Python features, improving error handling, and enhancing support for various media formats. The most important changes are grouped below.
General Improvements and Refactoring:
from __future__ import annotationsto all core processor files (__init__.py,audio_processor.py,base_processor.py,image_processor.py) for improved clarity and forward compatibility. [1] [2] [3] [4]str | None,list[str],Any) and clarified return types for better type safety. [1] [2] [3]Audio and Image Format Handling:
AudioProcessorto include.m4a,.ogg,.flac, and.aac, and improved format detection logic for URLs and data URLs.Validation and Error Handling:
Resource Management and Caching:
pathlib.Pathfor safer file operations and replaced someoscalls. Periodic cleanup of old files and cache entries is now more robust. [1] [2]__aenter__and__aexit__for resource cleanup.API and Method Consistency:
These changes collectively make the media processing utilities more robust, maintainable, and easier to use and extend for future development.