feat(lib): add files_from_zip helper for skill uploads#1219
Open
lyr408 wants to merge 1 commit intoanthropics:mainfrom
Open
feat(lib): add files_from_zip helper for skill uploads#1219lyr408 wants to merge 1 commit intoanthropics:mainfrom
lyr408 wants to merge 1 commit intoanthropics:mainfrom
Conversation
- Add files_from_zip() and async_files_from_zip() to anthropic.lib - Extracts files from zip archives into list[FileTypes] format - Skips directory entries and __MACOSX/ metadata automatically - Add comprehensive tests and usage example - Example demonstrates MIME type is optional in file tuples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds
files_from_zip()andasync_files_from_zip()helper functions toanthropic.lib, complementing the existingfiles_from_dir()helper.Motivation
Currently, uploading a skill from a zip archive requires manually constructing file tuples:
With this change, users can use a dedicated helper that extracts individual files from the zip:
Changes
src/anthropic/lib/_files.py— Addedfiles_from_zip(),async_files_from_zip(), and internal_read_zip()helperlist[FileTypes](2-tuples) consistent withfiles_from_dir()__MACOSX/metadatasrc/anthropic/lib/__init__.py— Exported the new functionstests/lib/test_files.py— 11 tests covering sync/async, edge cases, and mixed tuple format validationexamples/skills_from_zip.py— Usage example showing all three file upload patterns, including that the MIME type is optional in file tuplesAll changes are in
lib/,tests/, andexamples/— directories not affected by the code generator.