Skip to content

Commit 2a8af36

Browse files
committed
fix warnings, fmt
1 parent daa0915 commit 2a8af36

4 files changed

Lines changed: 33 additions & 16 deletions

File tree

python/nix_csi/copytocache.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ async def copyToCache(packagePath: Path):
3434
if pathInfoDrv.returncode == 0:
3535
paths += pathInfoDrv.stdout.splitlines()
3636
else:
37-
logger.debug(f"No derivation paths found for {packagePath} (normal if fetched from substituters)")
37+
logger.debug(
38+
f"No derivation paths found for {packagePath} (normal if fetched from substituters)"
39+
)
3840

3941
# Filter out .drv files and deduplicate (path-info runs return overlapping results)
4042
# Set comprehension {x for x in ...} creates a set with unique values
@@ -44,7 +46,9 @@ async def copyToCache(packagePath: Path):
4446
for attempt in range(6):
4547
if attempt > 0:
4648
exp_backoff = min(5 * (2 ** (attempt - 1)), 60)
47-
logger.warning(f"Retry {attempt}/6 copying to cache after {exp_backoff}s: {packagePath}")
49+
logger.warning(
50+
f"Retry {attempt}/6 copying to cache after {exp_backoff}s: {packagePath}"
51+
)
4852
await sleep(exp_backoff)
4953

5054
nixCopy = await run_captured(

python/nix_csi/identityservicer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ class IdentityServicer(csi_grpc.IdentityBase):
1212
async def GetPluginInfo(self, stream):
1313
request: csi_pb2.GetPluginInfoRequest | None = await stream.recv_message()
1414
if request is None:
15-
raise GRPCError(Status.INVALID_ARGUMENT, "Received None request in GetPluginInfo")
15+
raise GRPCError(
16+
Status.INVALID_ARGUMENT, "Received None request in GetPluginInfo"
17+
)
1618
reply = csi_pb2.GetPluginInfoResponse(
1719
name=CSI_PLUGIN_NAME, vendor_version=CSI_VENDOR_VERSION
1820
)
@@ -23,7 +25,10 @@ async def GetPluginCapabilities(self, stream):
2325
csi_pb2.GetPluginCapabilitiesRequest | None
2426
) = await stream.recv_message()
2527
if request is None:
26-
raise GRPCError(Status.INVALID_ARGUMENT, "Received None request in GetPluginCapabilities")
28+
raise GRPCError(
29+
Status.INVALID_ARGUMENT,
30+
"Received None request in GetPluginCapabilities",
31+
)
2732
reply = csi_pb2.GetPluginCapabilitiesResponse(
2833
capabilities=[
2934
csi_pb2.PluginCapability(

python/nix_csi/service.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ async def NodePublishVolume(self, stream):
119119

120120
logger.info(f"Publish {request.target_path}")
121121

122-
123122
if not request.volume_context.get("csi.storage.k8s.io/ephemeral"):
124-
raise GRPCError(Status.INTERNAL, "This CSI driver only supports ephemeral volumes")
123+
raise GRPCError(
124+
Status.INTERNAL, "This CSI driver only supports ephemeral volumes"
125+
)
125126

126127
async with self.volumeLocks[request.volume_id]:
127128
targetPath = Path(request.target_path)
@@ -509,16 +510,16 @@ async def NodeGetInfo(self, stream):
509510
reply = csi_pb2.NodeGetInfoResponse(node_id=node_name)
510511
await stream.send_message(reply)
511512

512-
async def NodeGetVolumeStats(self, _stream):
513+
async def NodeGetVolumeStats(self, stream):
513514
raise GRPCError(Status.UNIMPLEMENTED, "NodeGetVolumeStats not implemented")
514515

515-
async def NodeExpandVolume(self, _stream):
516+
async def NodeExpandVolume(self, stream):
516517
raise GRPCError(Status.UNIMPLEMENTED, "NodeExpandVolume not implemented")
517518

518-
async def NodeStageVolume(self, _stream):
519+
async def NodeStageVolume(self, stream):
519520
raise GRPCError(Status.UNIMPLEMENTED, "NodeStageVolume not implemented")
520521

521-
async def NodeUnstageVolume(self, _stream):
522+
async def NodeUnstageVolume(self, stream):
522523
raise GRPCError(Status.UNIMPLEMENTED, "NodeUnstageVolume not implemented")
523524

524525

python/nix_csi/subprocessing.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ async def try_captured(*args, timeout: float | None = None):
3131
raise GRPCError(
3232
Status.INTERNAL,
3333
f"{_format_command_preview(args)} failed: {result.returncode=}",
34-
result.combined
34+
result.combined,
3535
)
3636
return result
3737

3838

39-
async def try_console(*args, log_level: int = logging.DEBUG, timeout: float | None = None):
39+
async def try_console(
40+
*args, log_level: int = logging.DEBUG, timeout: float | None = None
41+
):
4042
result = await run_console(*args, log_level=log_level, timeout=timeout)
4143
if result.returncode != 0:
4244
raise GRPCError(
4345
Status.INTERNAL,
4446
f"{_format_command_preview(args)} failed: {result.returncode=}",
45-
result.combined
47+
result.combined,
4648
)
4749
return result
4850

@@ -53,7 +55,9 @@ async def run_captured(*args, timeout: float | None = None):
5355

5456

5557
# Run async subprocess, forward output to console and return returncode
56-
async def run_console(*args, log_level: int = logging.DEBUG, timeout: float | None = None):
58+
async def run_console(
59+
*args, log_level: int = logging.DEBUG, timeout: float | None = None
60+
):
5761
start_time = time.perf_counter()
5862
log_command(*args, log_level=log_level)
5963
proc = await asyncio.create_subprocess_exec(
@@ -84,12 +88,15 @@ async def stream_output(stream, buffer):
8488
stream_output(proc.stderr, stderr_data),
8589
proc.wait(),
8690
),
87-
timeout=timeout
91+
timeout=timeout,
8892
)
8993
except asyncio.TimeoutError:
9094
proc.kill()
9195
await proc.wait()
92-
raise GRPCError(Status.DEADLINE_EXCEEDED, f"Command timed out after {timeout}s: {_format_command_preview(args)}")
96+
raise GRPCError(
97+
Status.DEADLINE_EXCEEDED,
98+
f"Command timed out after {timeout}s: {_format_command_preview(args)}",
99+
)
93100

94101
elapsed_time = time.perf_counter() - start_time
95102
if elapsed_time > 5:

0 commit comments

Comments
 (0)