Skip to content

Commit b78d4c1

Browse files
committed
Add Ruff formatting.
1 parent 8cddaa5 commit b78d4c1

20 files changed

Lines changed: 561 additions & 421 deletions

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
- name: Lint (ruff)
3939
run: uv run ruff check
4040

41+
- name: Lint (format)
42+
run: uv run ruff format --diff
4143

4244
- name: Type check (mypy)
4345
run: uv run mypy .

developer-notes/FUSEError Performance.ipynb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@
9090
" except FUSEErrorExt as exc:\n",
9191
" a += exc.errno\n",
9292
" except:\n",
93-
" print('This should not happen')\n",
93+
" print(\"This should not happen\")\n",
9494
" return a\n",
9595
"\n",
96+
"\n",
9697
"def test_int():\n",
9798
" a = 0\n",
9899
" for i in range(100):\n",
@@ -101,7 +102,7 @@
101102
" except FUSEErrorInt as exc:\n",
102103
" a += exc.errno\n",
103104
" except:\n",
104-
" print('This should not happen')\n",
105+
" print(\"This should not happen\")\n",
105106
" return a"
106107
]
107108
},
@@ -151,13 +152,16 @@
151152
"outputs": [],
152153
"source": [
153154
"cache = dict()\n",
155+
"\n",
156+
"\n",
154157
"def getError(errno):\n",
155158
" try:\n",
156159
" return cache[errno]\n",
157160
" except KeyError:\n",
158161
" cache[errno] = FUSEErrorExt(errno)\n",
159162
" return cache[errno]\n",
160-
" \n",
163+
"\n",
164+
"\n",
161165
"def test_ext_cached():\n",
162166
" a = 0\n",
163167
" for i in range(100):\n",
@@ -166,7 +170,7 @@
166170
" except FUSEErrorExt as exc:\n",
167171
" a += exc.errno\n",
168172
" except:\n",
169-
" print('This should not happen')\n",
173+
" print(\"This should not happen\")\n",
170174
" return a"
171175
]
172176
},
@@ -210,6 +214,7 @@
210214
"def handler(i):\n",
211215
" return getError(i)\n",
212216
"\n",
217+
"\n",
213218
"def test_ext_direct():\n",
214219
" a = 0\n",
215220
" for i in range(100):\n",

developer-notes/Namedtuple.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"outputs": [],
4747
"source": [
4848
"from collections import namedtuple\n",
49-
"InvalRequestTup = namedtuple('InvalRequestTup', [ 'inode', 'attr_only' ])"
49+
"\n",
50+
"InvalRequestTup = namedtuple(\"InvalRequestTup\", [\"inode\", \"attr_only\"])"
5051
]
5152
},
5253
{

examples/hello.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,21 @@
4141

4242
log = logging.getLogger(__name__)
4343

44+
4445
class TestFs(pyfuse3.Operations):
4546
def __init__(self):
4647
super(TestFs, self).__init__()
4748
self.hello_name = b"message"
48-
self.hello_inode = pyfuse3.ROOT_INODE+1
49+
self.hello_inode = pyfuse3.ROOT_INODE + 1
4950
self.hello_data = b"hello world\n"
5051

5152
async def getattr(self, inode, ctx=None):
5253
entry = pyfuse3.EntryAttributes()
5354
if inode == pyfuse3.ROOT_INODE:
54-
entry.st_mode = (stat.S_IFDIR | 0o755)
55+
entry.st_mode = stat.S_IFDIR | 0o755
5556
entry.st_size = 0
5657
elif inode == self.hello_inode:
57-
entry.st_mode = (stat.S_IFREG | 0o644)
58+
entry.st_mode = stat.S_IFREG | 0o644
5859
entry.st_size = len(self.hello_data)
5960
else:
6061
raise pyfuse3.FUSEError(errno.ENOENT)
@@ -85,7 +86,11 @@ async def readdir(self, fh, start_id, token):
8586
# only one entry
8687
if start_id == 0:
8788
pyfuse3.readdir_reply(
88-
token, self.hello_name, await self.getattr(pyfuse3.InodeT(self.hello_inode)), 1)
89+
token,
90+
self.hello_name,
91+
await self.getattr(pyfuse3.InodeT(self.hello_inode)),
92+
1,
93+
)
8994
return
9095

9196
async def open(self, inode, flags, ctx):
@@ -97,11 +102,14 @@ async def open(self, inode, flags, ctx):
97102

98103
async def read(self, fh, off, size):
99104
assert fh == self.hello_inode
100-
return self.hello_data[off:off+size]
105+
return self.hello_data[off : off + size]
106+
101107

102108
def init_logging(debug=False):
103-
formatter = logging.Formatter('%(asctime)s.%(msecs)03d %(threadName)s: '
104-
'[%(name)s] %(message)s', datefmt="%Y-%m-%d %H:%M:%S")
109+
formatter = logging.Formatter(
110+
'%(asctime)s.%(msecs)03d %(threadName)s: [%(name)s] %(message)s',
111+
datefmt="%Y-%m-%d %H:%M:%S",
112+
)
105113
handler = logging.StreamHandler()
106114
handler.setFormatter(formatter)
107115
root_logger = logging.getLogger()
@@ -113,17 +121,22 @@ def init_logging(debug=False):
113121
root_logger.setLevel(logging.INFO)
114122
root_logger.addHandler(handler)
115123

124+
116125
def parse_args():
117126
'''Parse command line'''
118127

119128
parser = ArgumentParser()
120129

121-
parser.add_argument('mountpoint', type=str,
122-
help='Where to mount the file system')
123-
parser.add_argument('--debug', action='store_true', default=False,
124-
help='Enable debugging output')
125-
parser.add_argument('--debug-fuse', action='store_true', default=False,
126-
help='Enable FUSE debugging output')
130+
parser.add_argument('mountpoint', type=str, help='Where to mount the file system')
131+
parser.add_argument(
132+
'--debug', action='store_true', default=False, help='Enable debugging output'
133+
)
134+
parser.add_argument(
135+
'--debug-fuse',
136+
action='store_true',
137+
default=False,
138+
help='Enable FUSE debugging output',
139+
)
127140
return parser.parse_args()
128141

129142

examples/hello_asyncio.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,21 @@
4242
log = logging.getLogger(__name__)
4343
pyfuse3.asyncio.enable()
4444

45+
4546
class TestFs(pyfuse3.Operations):
4647
def __init__(self):
4748
super(TestFs, self).__init__()
4849
self.hello_name = b"message"
49-
self.hello_inode = pyfuse3.ROOT_INODE+1
50+
self.hello_inode = pyfuse3.ROOT_INODE + 1
5051
self.hello_data = b"hello world\n"
5152

5253
async def getattr(self, inode, ctx=None):
5354
entry = pyfuse3.EntryAttributes()
5455
if inode == pyfuse3.ROOT_INODE:
55-
entry.st_mode = (stat.S_IFDIR | 0o755)
56+
entry.st_mode = stat.S_IFDIR | 0o755
5657
entry.st_size = 0
5758
elif inode == self.hello_inode:
58-
entry.st_mode = (stat.S_IFREG | 0o644)
59+
entry.st_mode = stat.S_IFREG | 0o644
5960
entry.st_size = len(self.hello_data)
6061
else:
6162
raise pyfuse3.FUSEError(errno.ENOENT)
@@ -86,7 +87,11 @@ async def readdir(self, fh, start_id, token):
8687
# only one entry
8788
if start_id == 0:
8889
pyfuse3.readdir_reply(
89-
token, self.hello_name, await self.getattr(pyfuse3.InodeT(self.hello_inode)), 1)
90+
token,
91+
self.hello_name,
92+
await self.getattr(pyfuse3.InodeT(self.hello_inode)),
93+
1,
94+
)
9095
return
9196

9297
async def setxattr(self, inode, name, value, ctx):
@@ -107,11 +112,14 @@ async def open(self, inode, flags, ctx):
107112

108113
async def read(self, fh, off, size):
109114
assert fh == self.hello_inode
110-
return self.hello_data[off:off+size]
115+
return self.hello_data[off : off + size]
116+
111117

112118
def init_logging(debug=False):
113-
formatter = logging.Formatter('%(asctime)s.%(msecs)03d %(threadName)s: '
114-
'[%(name)s] %(message)s', datefmt="%Y-%m-%d %H:%M:%S")
119+
formatter = logging.Formatter(
120+
'%(asctime)s.%(msecs)03d %(threadName)s: [%(name)s] %(message)s',
121+
datefmt="%Y-%m-%d %H:%M:%S",
122+
)
115123
handler = logging.StreamHandler()
116124
handler.setFormatter(formatter)
117125
root_logger = logging.getLogger()
@@ -123,17 +131,22 @@ def init_logging(debug=False):
123131
root_logger.setLevel(logging.INFO)
124132
root_logger.addHandler(handler)
125133

134+
126135
def parse_args():
127136
'''Parse command line'''
128137

129138
parser = ArgumentParser()
130139

131-
parser.add_argument('mountpoint', type=str,
132-
help='Where to mount the file system')
133-
parser.add_argument('--debug', action='store_true', default=False,
134-
help='Enable debugging output')
135-
parser.add_argument('--debug-fuse', action='store_true', default=False,
136-
help='Enable FUSE debugging output')
140+
parser.add_argument('mountpoint', type=str, help='Where to mount the file system')
141+
parser.add_argument(
142+
'--debug', action='store_true', default=False, help='Enable debugging output'
143+
)
144+
parser.add_argument(
145+
'--debug-fuse',
146+
action='store_true',
147+
default=False,
148+
help='Enable FUSE debugging output',
149+
)
137150
return parser.parse_args()
138151

139152

0 commit comments

Comments
 (0)