Skip to content

Commit f173fd1

Browse files
committed
Add Ruff formatting.
1 parent 1017cab commit f173fd1

File tree

20 files changed

+515
-428
lines changed

20 files changed

+515
-428
lines changed

.github/workflows/test.yml

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

41+
- name: Lint (format)
42+
run: uv run ruff format --diff
43+
4144
- name: Type check (mypy)
4245
run: uv run mypy .
4346

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: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,21 @@
4343

4444
log = logging.getLogger(__name__)
4545

46+
4647
class TestFs(pyfuse3.Operations):
4748
def __init__(self):
4849
super(TestFs, self).__init__()
4950
self.hello_name = b"message"
50-
self.hello_inode = cast(InodeT, pyfuse3.ROOT_INODE+1)
51+
self.hello_inode = cast(InodeT, pyfuse3.ROOT_INODE + 1)
5152
self.hello_data = b"hello world\n"
5253

5354
async def getattr(self, inode, ctx=None):
5455
entry = pyfuse3.EntryAttributes()
5556
if inode == pyfuse3.ROOT_INODE:
56-
entry.st_mode = (stat.S_IFDIR | 0o755)
57+
entry.st_mode = stat.S_IFDIR | 0o755
5758
entry.st_size = 0
5859
elif inode == self.hello_inode:
59-
entry.st_mode = (stat.S_IFREG | 0o644)
60+
entry.st_mode = stat.S_IFREG | 0o644
6061
entry.st_size = len(self.hello_data)
6162
else:
6263
raise pyfuse3.FUSEError(errno.ENOENT)
@@ -87,8 +88,7 @@ async def readdir(self, fh, start_id, token):
8788

8889
# only one entry
8990
if start_id == 0:
90-
pyfuse3.readdir_reply(
91-
token, self.hello_name, await self.getattr(self.hello_inode), 1)
91+
pyfuse3.readdir_reply(token, self.hello_name, await self.getattr(self.hello_inode), 1)
9292
return
9393

9494
async def open(self, inode, flags, ctx):
@@ -101,11 +101,14 @@ async def open(self, inode, flags, ctx):
101101

102102
async def read(self, fh, off, size):
103103
assert fh == self.hello_inode
104-
return self.hello_data[off:off+size]
104+
return self.hello_data[off : off + size]
105+
105106

106107
def init_logging(debug=False):
107-
formatter = logging.Formatter('%(asctime)s.%(msecs)03d %(threadName)s: '
108-
'[%(name)s] %(message)s', datefmt="%Y-%m-%d %H:%M:%S")
108+
formatter = logging.Formatter(
109+
'%(asctime)s.%(msecs)03d %(threadName)s: [%(name)s] %(message)s',
110+
datefmt="%Y-%m-%d %H:%M:%S",
111+
)
109112
handler = logging.StreamHandler()
110113
handler.setFormatter(formatter)
111114
root_logger = logging.getLogger()
@@ -117,17 +120,19 @@ def init_logging(debug=False):
117120
root_logger.setLevel(logging.INFO)
118121
root_logger.addHandler(handler)
119122

123+
120124
def parse_args():
121125
'''Parse command line'''
122126

123127
parser = ArgumentParser()
124128

125-
parser.add_argument('mountpoint', type=str,
126-
help='Where to mount the file system')
127-
parser.add_argument('--debug', action='store_true', default=False,
128-
help='Enable debugging output')
129-
parser.add_argument('--debug-fuse', action='store_true', default=False,
130-
help='Enable FUSE debugging output')
129+
parser.add_argument('mountpoint', type=str, help='Where to mount the file system')
130+
parser.add_argument(
131+
'--debug', action='store_true', default=False, help='Enable debugging output'
132+
)
133+
parser.add_argument(
134+
'--debug-fuse', action='store_true', default=False, help='Enable FUSE debugging output'
135+
)
131136
return parser.parse_args()
132137

133138

examples/hello_asyncio.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,21 @@
4444
log = logging.getLogger(__name__)
4545
pyfuse3.asyncio.enable()
4646

47+
4748
class TestFs(pyfuse3.Operations):
4849
def __init__(self):
4950
super(TestFs, self).__init__()
5051
self.hello_name = b"message"
51-
self.hello_inode = cast(InodeT, pyfuse3.ROOT_INODE+1)
52+
self.hello_inode = cast(InodeT, pyfuse3.ROOT_INODE + 1)
5253
self.hello_data = b"hello world\n"
5354

5455
async def getattr(self, inode, ctx=None):
5556
entry = pyfuse3.EntryAttributes()
5657
if inode == pyfuse3.ROOT_INODE:
57-
entry.st_mode = (stat.S_IFDIR | 0o755)
58+
entry.st_mode = stat.S_IFDIR | 0o755
5859
entry.st_size = 0
5960
elif inode == self.hello_inode:
60-
entry.st_mode = (stat.S_IFREG | 0o644)
61+
entry.st_mode = stat.S_IFREG | 0o644
6162
entry.st_size = len(self.hello_data)
6263
else:
6364
raise pyfuse3.FUSEError(errno.ENOENT)
@@ -88,8 +89,7 @@ async def readdir(self, fh, start_id, token):
8889

8990
# only one entry
9091
if start_id == 0:
91-
pyfuse3.readdir_reply(
92-
token, self.hello_name, await self.getattr(self.hello_inode), 1)
92+
pyfuse3.readdir_reply(token, self.hello_name, await self.getattr(self.hello_inode), 1)
9393
return
9494

9595
async def setxattr(self, inode, name, value, ctx):
@@ -111,11 +111,14 @@ async def open(self, inode, flags, ctx):
111111

112112
async def read(self, fh, off, size):
113113
assert fh == self.hello_inode
114-
return self.hello_data[off:off+size]
114+
return self.hello_data[off : off + size]
115+
115116

116117
def init_logging(debug=False):
117-
formatter = logging.Formatter('%(asctime)s.%(msecs)03d %(threadName)s: '
118-
'[%(name)s] %(message)s', datefmt="%Y-%m-%d %H:%M:%S")
118+
formatter = logging.Formatter(
119+
'%(asctime)s.%(msecs)03d %(threadName)s: [%(name)s] %(message)s',
120+
datefmt="%Y-%m-%d %H:%M:%S",
121+
)
119122
handler = logging.StreamHandler()
120123
handler.setFormatter(formatter)
121124
root_logger = logging.getLogger()
@@ -127,17 +130,19 @@ def init_logging(debug=False):
127130
root_logger.setLevel(logging.INFO)
128131
root_logger.addHandler(handler)
129132

133+
130134
def parse_args():
131135
'''Parse command line'''
132136

133137
parser = ArgumentParser()
134138

135-
parser.add_argument('mountpoint', type=str,
136-
help='Where to mount the file system')
137-
parser.add_argument('--debug', action='store_true', default=False,
138-
help='Enable debugging output')
139-
parser.add_argument('--debug-fuse', action='store_true', default=False,
140-
help='Enable FUSE debugging output')
139+
parser.add_argument('mountpoint', type=str, help='Where to mount the file system')
140+
parser.add_argument(
141+
'--debug', action='store_true', default=False, help='Enable debugging output'
142+
)
143+
parser.add_argument(
144+
'--debug-fuse', action='store_true', default=False, help='Enable FUSE debugging output'
145+
)
141146
return parser.parse_args()
142147

143148

0 commit comments

Comments
 (0)