Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6ce9ea9
Switch to uv for dependency management.
Light2Dark Jun 18, 2026
4dc94bd
Rework CI with uv setup and split jobs.
Light2Dark Jun 18, 2026
7b423a2
Bump pre-commit hook versions.
Light2Dark Jun 18, 2026
e5508e9
move checkout back to workflow
Light2Dark Jun 18, 2026
606de4a
remove uv lock
Light2Dark Jun 20, 2026
05a9972
add uv.lock to gitignore
Light2Dark Jun 20, 2026
56bbae3
move to src layout
Light2Dark Jun 22, 2026
85f94ed
update readme
Light2Dark Jun 24, 2026
d24bb61
update note
Light2Dark Jun 24, 2026
0fc17a5
fix link
Light2Dark Jun 24, 2026
3292e55
add pyrefly typechecker
Light2Dark Jun 26, 2026
dd10432
set venv on path for pre-commit
Light2Dark Jun 26, 2026
f53415f
add comment
Light2Dark Jun 26, 2026
0048b36
Merge pull request #2 from Light2Dark/sham/upgrade-repo-v2
Light2Dark Jun 26, 2026
4a6883e
add logo, docs
Light2Dark Jun 27, 2026
6b57392
Merge pull request #4 from Light2Dark/sham/update-readme-contributing
Light2Dark Jun 27, 2026
6a050bf
update links, remove text
Light2Dark Jun 27, 2026
7846d04
Merge pull request #5 from Light2Dark/sham/docs-addition
Light2Dark Jun 27, 2026
601e107
add pytest-cov
Light2Dark Jun 27, 2026
f749f52
Merge pull request #6 from Light2Dark/sham/add-test-coverage
Light2Dark Jun 27, 2026
5a7c984
check root id is valid
Light2Dark Jun 27, 2026
4bf33d8
validate root_file_id is a folder
Light2Dark Jun 27, 2026
6e169ec
test: add root_file_id integration tests and FS factory fixture
Light2Dark Jun 27, 2026
dbd70b0
Merge pull request #7 from Light2Dark/sham/validate-root-id
Light2Dark Jun 28, 2026
f64def3
validate drive/root consistency and accept drive id or name
Light2Dark Jun 28, 2026
9f18332
Merge pull request #8 from Light2Dark/sham/validate-drive-root-consis…
Light2Dark Jun 28, 2026
e87c16e
update image, add service account docs
Light2Dark Jun 28, 2026
70f987f
Merge pull request #9 from Light2Dark/update-contributing-and-image
Light2Dark Jun 28, 2026
c24cf01
add unit tests, break up into folders, add integration tests
Light2Dark Jun 28, 2026
fc65ce8
address review feedback on test suite
Light2Dark Jun 28, 2026
3fee9af
Merge pull request #10 from Light2Dark/sham/add-tests
Light2Dark Jun 28, 2026
103ad3a
add docstring for main funcs
Light2Dark Jun 29, 2026
5953069
Merge pull request #12 from Light2Dark/sham/add-docstrings
Light2Dark Jun 29, 2026
788d3dc
add templates
Light2Dark Jun 29, 2026
230a16d
95% coverage
Light2Dark Jun 29, 2026
de41a17
Merge pull request #13 from Light2Dark/sham/add-templates
Light2Dark Jun 29, 2026
c6764f1
Merge pull request #14 from Light2Dark/sham/enforce-coverage
Light2Dark Jun 29, 2026
43be0bf
remove unecessary name
Light2Dark Jun 29, 2026
e20e982
Merge pull request #16 from Light2Dark/sham/typos
Light2Dark Jun 29, 2026
475f9e2
Tighten typing in core.py and align with fsspec API
Light2Dark Jun 29, 2026
4f92025
Add typed Drive schemas, FileInfo TypedDict, and ls overloads
Light2Dark Jun 29, 2026
f47f6f8
Address PR review: normalize PathLike in _rm and GoogleDriveFile
Light2Dark Jun 29, 2026
2157bf2
Merge pull request #17 from Light2Dark/sham/typing-cleanup-core
Light2Dark Jun 29, 2026
12d411d
Fix export() and validate export MIME types
Light2Dark Jun 29, 2026
ef644a4
Restore srv deprecated-alias property and its test
Light2Dark Jun 29, 2026
cd2964c
Merge pull request #47 from Light2Dark/sham/fix-export
Light2Dark Jun 29, 2026
5e37a04
Update existing files in place instead of creating duplicates (#22)
Light2Dark Jun 29, 2026
4d28bac
Reject directory targets on wb open; tighten info typing
Light2Dark Jun 29, 2026
1e1d540
Merge pull request #48 from Light2Dark/sham/fix-overwrite-duplicate
Light2Dark Jun 29, 2026
a57ae42
Merge remote-tracking branch 'upstream/master'
Light2Dark Jun 30, 2026
44bec38
Merge pull request #50 from Light2Dark/sham/merge
Light2Dark Jun 30, 2026
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
66 changes: 66 additions & 0 deletions .agents/verifying-drive-api-params.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Verifying Google Drive API parameters

When adding or changing a Drive API call, **verify each parameter against the
live discovery document** before trusting it. Do not rely on:

- **Type stubs** (`googleapiclient-stubs`). Most methods are typed
`def method(self, *, fileId, ..., **kwargs)`. The `**kwargs` swallows *any*
keyword, so the stub accepting `supportsAllDrives=True` proves only that
Python won't raise — not that the API supports the parameter.
- **Human docs / blog posts / memory.** They lag, omit per-method differences,
and frequently copy a parameter (like `supportsAllDrives`) onto methods that
don't actually take it.

The discovery document is the source of truth: the Python client is generated
from it, and it lists the exact parameters each method accepts.

## How to check

```bash
# Fetch once
curl -s "https://www.googleapis.com/discovery/v1/apis/drive/v3/rest" -o drive_v3.json

# List the accepted parameters for a given method, e.g. files.export
uv run python -c "
import json
d = json.load(open('drive_v3.json'))
m = d['resources']['files']['methods']['export'] # <resource>.methods.<method>
print(sorted(m.get('parameters', {}).keys()))
"
```

Swap `'files'` / `'export'` for the resource and method you care about
(`files.get`, `files.list`, `files.create`, `drives.list`, ...).

To see a parameter's type / required-ness / description:

```bash
uv run python -c "
import json
d = json.load(open('drive_v3.json'))
import pprint; pprint.pprint(d['resources']['files']['methods']['export']['parameters'])
"
```

## Worked example (the bug this guide came from)

```
files.export -> ['fileId', 'mimeType'] # NO supportsAllDrives
files.get -> ['acknowledgeAbuse', 'fileId', 'includeLabels',
'includePermissionsForView', 'supportsAllDrives',
'supportsTeamDrives'] # has it
```

`files.export`/`export_media` accept **only** `fileId` and `mimeType`. Passing
`supportsAllDrives=True` was silently serialized as an ignored query param —
no error, mocked tests still passed — but it was wrong. `files.get` *does*
take it, which is why it's correct elsewhere in the code. Per-method
differences like this are exactly what the discovery doc catches and stubs hide.

## Checklist when touching a Drive call

1. Find the method: `resources.<resource>.methods.<method>` in the discovery doc.
2. Confirm **every** kwarg you pass is in that method's `parameters`.
3. If a kwarg isn't listed, remove it (it does nothing) or find the right method.
4. Remember mocked unit tests won't catch an unsupported-but-ignored param —
the discovery doc is the only cheap pre-flight check.
57 changes: 57 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: 🐛 Bug report
description: Report a bug or unexpected behavior in gdrive_fsspec
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thank you for contributing to gdrive_fsspec! ✊
Please provide as much information as possible to help us reproduce and fix your issue quickly.
- type: checkboxes
id: checks
attributes:
label: Initial Checks
description: Just making sure we're on the same page.
options:
- label: I'm using the [latest version](https://github.com/Light2Dark/gdrive_fsspec/releases/latest) of gdrive_fsspec
required: true
- label: I've searched for my issue in [the issue tracker](https://github.com/Light2Dark/gdrive_fsspec/issues) before opening this issue
required: true
- type: textarea
id: description
attributes:
label: Description
description: |
Please explain what you're seeing and what you would expect to see.
- **A line of code is worth a thousand words**: you can include a minimal, reproducible example below.
validations:
required: true
- type: textarea
id: example
attributes:
label: Minimal, Reproducible Example
description: >
If at all possible, please add a self-contained,
[minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)
that demonstrates the bug.
(This will be automatically formatted as code, so no need for backticks.)
placeholder: |
from gdrive_fsspec import GoogleDriveFileSystem

fs = GoogleDriveFileSystem(
token="browser",
skip_instance_cache=True
)
...
render: Python
- type: textarea
id: version
attributes:
label: Python, gdrive_fsspec & fsspec version
description: |
Which version of Python, gdrive_fsspec, and fsspec are you using?
value: |
- Python:
- gdrive_fsspec:
validations:
required: true
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: 💬 Questions & Discussions
url: https://github.com/Light2Dark/gdrive_fsspec/discussions
about: Have a question or want to discuss an idea? Start a discussion here instead of opening an issue.
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 🚀 Feature Request
description: "Suggest a new feature for gdrive_fsspec"
labels: ["feature"]
body:
- type: markdown
attributes:
value: Thank you for contributing to gdrive_fsspec! ✊
- type: textarea
id: description
attributes:
label: Description
description: |
Please give as much detail as possible about the feature you would like to suggest. 🙏
You might like to add:
* A demo of how code might look when using the feature
* Your use case(s) for the feature
* Reference to other projects that have a similar feature
validations:
required: true
- type: textarea
id: references
attributes:
label: References
description: |
Please add any links or references that might help us understand your feature request better. 📚
16 changes: 16 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Summary

<!-- Brief description of the changes -->

## Linked Issue

<!-- REQUIRED: Every PR must have a linked issue. Open one first if it doesn't exist. -->
<!-- Use: Fixes #... or Closes #... -->

Fixes #

## Checklist

- [ ] Linked issue exists and is referenced above
- [ ] Tests added/updated for new behavior
- [ ] Docstrings use RST double backticks for inline code (e.g. ``drive``, not `drive`)
39 changes: 38 additions & 1 deletion .github/workflows/tests.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,25 @@ jobs:

- uses: ./.github/actions/setup

# pyrefly-check uses language: system and expects pyrefly on PATH.
- name: Run pre-commit
run: uvx pre-commit run --all-files
run: PATH="$PWD/.venv/bin:$PATH" uvx pre-commit run --all-files

typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false

- uses: ./.github/actions/setup
with:
python-version: "3.13"

- name: Run pyrefly
run: uv run pyrefly check --output-format=github

test:
name: Test (Python ${{ matrix.python-version }})
Expand All @@ -49,6 +66,26 @@ jobs:
- name: Run unit tests
run: uv run pytest -v

coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false

- uses: ./.github/actions/setup
with:
python-version: "3.13"

- name: Run tests with coverage
run: |
uv run pytest \
--cov=gdrive_fsspec \
--cov-report=term-missing \
--cov-report=xml \
--cov-fail-under=95

integration:
name: Integration tests
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ repos:
args: [--fix, --show-fixes]
- id: ruff-format
types_or: [python]
- repo: https://github.com/facebook/pyrefly-pre-commit
rev: 1.1.1 # Note: this is the version of the pre-commit hook, NOT the pyrefly version used for type checking
hooks:
- id: pyrefly-check
name: Pyrefly (type checking)
pass_filenames: false # Recommended to do full repo checks. However, you can change this to `true` to only check changed files
language: system # Use system-installed pyrefly
- repo: https://github.com/codespell-project/codespell
rev: v2.4.2
hooks:
Expand Down
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Set up the environment as described in [CONTRIBUTING.md](CONTRIBUTING.md).

To verify Google Drive APIs, refer to [verifying-drive-api-params.md](.agents/verifying-drive-api-params.md).
100 changes: 100 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Contributing to gdrive-fsspec

Thanks for your interest in contributing! This guide covers local setup, running tests, and the checks CI runs on pull requests.

## Prerequisites

Install `uv` and `pre-commit`:

- [`uv` install docs](https://docs.astral.sh/uv/getting-started/installation/)
- [`pre-commit` install docs](https://pre-commit.com/#install)

## Setup

1. Fork the repository on GitHub, then clone your fork:

```sh
git clone git@github.com:<your-username>/gdrive-fsspec.git
cd gdrive-fsspec
```

2. Create the virtual environment and install dependencies:

```sh
uv sync --all-groups
```

3. Install pre-commit hooks:

```sh
pre-commit install
```

## Running checks locally

CI runs the same checks you can run before pushing:

**Lint** (ruff, codespell, formatting, and more via pre-commit):

```sh
pre-commit run --all-files
```

**Type checking** (pyrefly):

```sh
uv run pyrefly check
```

**Unit tests** (default; no Google Drive credentials needed):

```sh
uv run pytest -v
```

**Coverage** (same unit tests; reports missing lines; CI requires at least 95%):

```sh
uv run pytest --cov=gdrive_fsspec --cov-report=term-missing
```

## Docstrings

Use reStructuredText (RST) double backticks for inline code in docstrings—for example, ``drive`` rather than `drive`. This matches the existing codebase and renders correctly with Sphinx-style tooling.

## Integration tests

Integration tests use a real Google Drive account and a directory named `gdrive_fsspec_testdir` on Drive.

```sh
uv run pytest -v -m integration
```

Set these environment variables before running them:

- `GDRIVE_FSSPEC_CREDENTIALS_PATH` — path to a service-account JSON, or the JSON string (starting with `{`). Required when using `service_account` (the default).
- `GDRIVE_FSSPEC_CREDENTIALS_TYPE` — token type (`service_account` default; use `cache` or `browser` for user OAuth).
- `GDRIVE_FSSPEC_DRIVE` — **Shared Drive name**. Required for service-account upload tests.

Service accounts cannot own files in Google Drive and have no storage quota. Uploads must target a [Shared Drive](https://developers.google.com/workspace/drive/api/guides/about-shareddrives) where the service account is a member with at least **Contributor** access. See [Google's storage-limit errors](https://developers.google.com/workspace/drive/api/guides/handle-errors#storage-limit).

For a personal Drive (no Shared Drive), use user OAuth instead: `GDRIVE_FSSPEC_CREDENTIALS_TYPE=cache` after a one-time `browser` login.

To run **all** tests (unit + integration), override the default marker filter:

```sh
uv run pytest -v -m ""
```

> **Note:** Integration tests do not run on PRs from forks, because those workflows cannot use repository secrets. They run on pushes to `master` and same-repo PRs. Google Drive has no good emulator; see [this discussion](https://github.com/fsspec/gdrive-fsspec/issues/23#issuecomment-2030367587).


### Creating a service account

1. Enable Google Drive API for the project in the Google Cloud Console.
2. Create a new service account.
3. Grant the service account permissions (likely Editor role, as there is no fine-grained Drive permissions).
4. Create a new key and download the JSON file.

5. To add a shared drive to the service account, get the service account email.
6. From the shared drive, add the service account email as a member with at least Contributor access.
Loading
Loading