Repository navigation
better types rewrite - #69
Closed
Light2Dark wants to merge 51 commits into
Closed
Light2Dark wants to merge 51 commits into
Light2Dark wants to merge 51 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
add uv, pyrefly, commit CI
add logo, docs, contributing.md
update links, remove text
add test-coverage
Request mimeType and reject non-folder IDs so a regular file passed as
root_file_id no longer masquerades as an empty directory under ls("").
Add a TODO for the conflicting drive vs shared-drive root_file_id case
(issue #2) to handle in a follow-up.
Co-authored-by: Cursor <cursoragent@cursor.com>
Add integration tests asserting a file ID is rejected as root (NotADirectoryError) and a folder ID lists its children. Introduce a typed DriveConfig + make_fs factory fixture in conftest so live filesystems are built from env in one place and tests can create multiple instances with a shared teardown. Add tests to pyrefly search-path and document Drive API constants. Co-authored-by: Cursor <cursoragent@cursor.com>
check root id is valid
Enforce that a scoped drive and root_file_id agree: reject a folder root whose driveId differs from the configured drive, and raise on a shared-drive root_file_id that conflicts with an already-set drive (previously a silent no-op). Also resolve the `drive` argument by id or name (was name-only) and correct the docstring accordingly. Co-authored-by: Cursor <cursoragent@cursor.com>
…tency Validate drive/root consistency; accept drive id or name
update image, add service account docs
- conftest: collapse unreachable pytest.skip branch in make_fs
- test_core_fs: replace export AttributeError test with strict xfail
documenting that export() calls a nonexistent path_to_file_id
- test_integration: assert info("") against the real root, not TESTDIR;
drop dangling issue reference from dircache xfail reason
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
add unit tests, break up into folders, add integration tests
add docstring for main funcs
add templates
remove unecessary name
- Add PathLike type alias and _path_str() helper to normalize paths
- Accept os.PathLike inputs across mkdir/makedirs/rm/ls/info/_open/export
- Avoid passing pageToken=None to drives().list / files.list
- Make _finfo_from_response non-mutating ({**f, **info})
- Rename rm_file override to _rm (fsspec's actual override point)
- _upload_chunk returns None to match base signature
- Drop pyrefly ignore pragmas now that types check cleanly
Update tests for the _rm rename and the _upload_chunk return change.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Add types.py with FileInfo TypedDict (fsspec required fields + Drive partial-response fields) and re-exported drive.v3 schema types - Annotate _finfo_from_response / info / mkdir against the new types - Add @overload stubs to ls so detail=True is typed list[FileInfo] and detail=False is typed list[str] for callers - Keep mkdir returning the Drive API response (revert to fsspec-superset behavior) to avoid a breaking change for callers needing the new id Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Normalize PathLike at the start of _rm so info lookup, logging, parent resolution, dircache name comparison, and cache eviction all use one string; a pathlib.Path previously deleted the Drive object but then left stale dircache entries - Normalize PathLike in GoogleDriveFile.__init__ before it is used as a str for super().__init__ and fs.info() - Fix stale _upload_chunk docstring (now returns None, not True) - Assert _upload_chunk(final=True) is None to cover the new contract - Add docstrings for _path_str, _open, and types._FsspecRequired - Add regression tests for both PathLike normalization fixes Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Tighten typing in core.py and align with fsspec API
export() was completely broken: it called the undefined self.path_to_file_id (GitHub #32 / issues.md #15), always raising AttributeError. Resolve the id via self.info(path)["id"], consistent with the rest of the class. Switch from files.export().execute() (capped at 10 MB) to files.export_media streamed through MediaIoBaseDownload, so arbitrarily large exports work. Drop the unsupported supportsAllDrives kwarg — the v3 discovery doc shows files.export accepts only fileId + mimeType. Add an export_formats cached_property (from the Drive about resource) and validate the requested mime_type against the file's source type, raising a clear ValueError listing the supported targets instead of a cryptic 400 from the API. Remove the obsolete test_srv_is_deprecated_alias (the srv deprecation warning was removed from the source). Docs: add .agents/verifying-drive-api-params.md (how to verify Drive params against the live discovery doc rather than stubs) and AGENTS.md pointing to it. Streaming export to a caller-provided output is tracked separately in #46. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Revert the change that turned `srv` into a plain attribute; restore the property that emits a DeprecationWarning, the `warnings` import, and test_srv_is_deprecated_alias. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fix export() and validate export MIME types
Opening an existing path in "wb" mode (or fs.put/pipe) always POSTed a new
file resource, so overwriting produced two identically-named children. Drive
allows that, and the library then raises MultipleFilesError on the next ls/info.
GoogleDriveFile now looks up the path's id on open; if it exists, the resumable
session PATCHes …/files/{id} rather than POSTing a new resource, and the commit
updates the parent dircache entry in place. A pre-existing duplicate
(MultipleFilesError) propagates rather than spawning a third copy. The id lookup
runs before super().__init__() so a failed open never leaves a flushable buffer.
Verified against live Drive: overwrite yields one entry with the id preserved
(in-place PATCH, not delete+recreate).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Address PR review: opening an existing directory in "wb" mode resolved the folder's id as an overwrite target, so bytes would be PATCHed onto a folder. Raise IsADirectoryError instead, before any id is stored. Cast the info() result to FileInfo so the type/id accesses are statically checked. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update existing files in place instead of creating duplicates (#22)
switch to uv, and modernize CI yaml (fsspec#58)
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.
Co-authored-by: Cursor cursoragent@cursor.com