Skip to content

Commit d14bab2

Browse files
Enforce ruff rule RUF012
RUF012 Mutable class attributes should be annotated with `typing.ClassVar`
1 parent 01ecda4 commit d14bab2

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

fsspec/gui.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,17 @@ def show(self, threads=False):
169169
class SingleSelect(SigSlot):
170170
"""A multiselect which only allows you to select one item for an event"""
171171

172-
signals = ["_selected", "selected"] # the first is internal
173-
slots = ["set_options", "set_selection", "add", "clear", "select"]
172+
signals: ClassVar[Sequence[str]] = [
173+
"_selected",
174+
"selected",
175+
] # the first is internal
176+
slots: ClassVar[Sequence[str]] = [
177+
"set_options",
178+
"set_selection",
179+
"add",
180+
"clear",
181+
"select",
182+
]
174183

175184
def __init__(self, **kwargs):
176185
self.kwargs = kwargs
@@ -212,7 +221,7 @@ class FileSelector(SigSlot):
212221
them as the output of a cell, or in a separate browser tab using ``.show()``.
213222
"""
214223

215-
signals = [
224+
signals: ClassVar[Sequence[str]] = [
216225
"protocol_changed",
217226
"selection_changed",
218227
"directory_entered",
@@ -221,7 +230,7 @@ class FileSelector(SigSlot):
221230
"go_clicked",
222231
"filters_changed",
223232
]
224-
slots = ["set_filters", "go_home"]
233+
slots: ClassVar[Sequence[str]] = ["set_filters", "go_home"]
225234

226235
def __init__(self, url=None, filters=None, ignore=None, kwargs=None):
227236
"""

fsspec/implementations/memory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from errno import ENOTEMPTY
66
from io import BytesIO
77
from pathlib import PurePath, PureWindowsPath
8-
from typing import Any, ClassVar
8+
from typing import Any, ClassVar, Sequence
99

1010
from fsspec import AbstractFileSystem
1111
from fsspec.implementations.local import LocalFileSystem
@@ -22,7 +22,7 @@ class MemoryFileSystem(AbstractFileSystem):
2222
"""
2323

2424
store: ClassVar[dict[str, Any]] = {} # global, do not overwrite!
25-
pseudo_dirs = [""] # global, do not overwrite!
25+
pseudo_dirs: ClassVar[Sequence[str]] = [""] # global, do not overwrite!
2626
protocol = "memory"
2727
root_marker = "/"
2828

fsspec/implementations/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class MultiProtocolFileSystem(LocalFileSystem):
13-
protocol = ["file", "other"]
13+
protocol = ("file", "other")
1414

1515

1616
FILESYSTEMS = {

fsspec/implementations/tests/test_archive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ class TestAnyArchive:
214214
will adhere to the same specification.
215215
"""
216216

217-
scenarios = [
217+
scenarios = (
218218
scenario_zip,
219219
scenario_tar,
220220
scenario_targz,
221221
scenario_tarbz2,
222222
scenario_tarxz,
223223
scenario_libarchive,
224-
]
224+
)
225225

226226
def test_repr(self, scenario: ArchiveTestScenario):
227227
with scenario.provider() as archive:

fsspec/tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from collections import ChainMap
77
from http.server import BaseHTTPRequestHandler, HTTPServer
88
from types import SimpleNamespace
9+
from typing import ClassVar
910

1011
import pytest
1112

@@ -45,7 +46,7 @@ def reset_files():
4546

4647

4748
class HTTPTestHandler(BaseHTTPRequestHandler):
48-
static_files = {
49+
static_files: ClassVar[dict[str, bytes]] = {
4950
"/index/realfile": data,
5051
"/index/otherfile": data,
5152
"/index": _make_index_listing,
@@ -55,7 +56,7 @@ class HTTPTestHandler(BaseHTTPRequestHandler):
5556
"/simple/dir/": _make_listing("/simple/dir/file"),
5657
"/simple/dir/file": data,
5758
}
58-
dynamic_files = {}
59+
dynamic_files: ClassVar[dict[str, bytes]] = {}
5960

6061
files = ChainMap(dynamic_files, static_files)
6162

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ select = [
178178
# "PT", enable in later PR
179179
"PYI",
180180
"RUF006",
181+
"RUF012",
181182
"RUF015",
182183
"RUF024",
183184
"SIM",

0 commit comments

Comments
 (0)