Skip to content

Commit 07d5abd

Browse files
xcp/accessor.py: Fix static analyis warnings for self.location
Fix static analysis warnings in `MountingAccessor` by checking `self.location` to not be `None` before accessing it: - MountingAccessor's self.location changes between `str` and `None` depending on the state of the MountingAccessor object (initialized, started, stopped/finished). The assert lets checkers know it is str when it is used in these locations. Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
1 parent dcd3c78 commit 07d5abd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

xcp/accessor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,13 @@ def finish(self):
155155
return
156156
self.start_count -= 1
157157
if self.start_count == 0:
158+
assert self.location
158159
mount.umount(self.location)
159160
os.rmdir(self.location)
160161
self.location = None
161162

162163
def writeFile(self, in_fh, out_name):
164+
assert self.location
163165
logger.info("Copying to %s" % os.path.join(self.location, out_name))
164166
out_fh = open(os.path.join(self.location, out_name), "wb")
165167
return self._writeFile(in_fh, out_fh)

0 commit comments

Comments
 (0)