Skip to content

Allow per-instance filesystem protocols - #2117

Merged
martindurant merged 1 commit into
fsspec:masterfrom
be-student:codex/1800-instance-protocol
Sep 9, 2026
Merged

Allow per-instance filesystem protocols#2117
martindurant merged 1 commit into
fsspec:masterfrom
be-student:codex/1800-instance-protocol

Conversation

@be-student

Copy link
Copy Markdown
Contributor

Closes #1800

AbstractFileSystem.protocol is currently declared as a ClassVar, so type checkers reject filesystem adapters that choose their protocol from constructor state. This removes the ClassVar restriction while preserving the existing string-or-tuple type and class default.

Concrete implementations with a fixed protocol can continue declaring their own ClassVar. The changelog now documents support for per-instance protocol selection.

Validation:

  • The issue-shaped Pyright fixture fails before the change with Attribute "protocol" cannot be assigned through a class instance because it is a ClassVar and passes afterward with 0 errors.
  • fsspec/tests/test_spec.py portable tests: 186 passed, 10 skipped, 1 xfailed. The 52 excluded Bash-reference cases require GNU stat -c and fail unchanged on macOS.
  • Ruff check, Ruff format check, and git diff --check pass.

@martindurant

Copy link
Copy Markdown
Member

OK, I suppose so; this is typing getting things wrong. It it a class variable usually....

@martindurant
martindurant merged commit b9cf257 into fsspec:master Sep 9, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't type protocol as ClassVar

2 participants