Add flake8-simplicity rules
This commit is contained in:
parent
d7d1f42b2c
commit
6b1e40f689
7 changed files with 38 additions and 49 deletions
|
|
@ -210,9 +210,8 @@ class ScanDirectoryManager:
|
|||
not exist.
|
||||
"""
|
||||
file_path = os.path.join(self.path_for(scan_name), filename)
|
||||
if check_exists:
|
||||
if not os.path.exists(file_path):
|
||||
return None
|
||||
if check_exists and not os.path.exists(file_path):
|
||||
return None
|
||||
return file_path
|
||||
|
||||
@requires_lock
|
||||
|
|
@ -225,9 +224,8 @@ class ScanDirectoryManager:
|
|||
then the path is returned anyway
|
||||
"""
|
||||
file_path = os.path.join(self.img_dir_for(scan_name), filename)
|
||||
if check_exists:
|
||||
if not os.path.exists(file_path):
|
||||
return None
|
||||
if check_exists and not os.path.exists(file_path):
|
||||
return None
|
||||
return file_path
|
||||
|
||||
def get_final_stitch_path(self, scan_name: str) -> Optional[str]:
|
||||
|
|
@ -528,7 +526,8 @@ class ScanDirectory:
|
|||
"""
|
||||
zip_fname = os.path.join(self.dir_path, "images.zip")
|
||||
|
||||
if os.path.isfile(zip_fname):
|
||||
# Use noqa as converting this into a 1 liner is not more readable.
|
||||
if os.path.isfile(zip_fname): # noqa: SIM108
|
||||
# get a list of files in the existing zip
|
||||
zip_files = get_files_in_zip(zip_fname)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -163,10 +163,7 @@ class ScanPlanner:
|
|||
|
||||
# If focussed locations exist return closest location, favouring most recent
|
||||
closest_pos = self.closest_focus_site(next_location)
|
||||
if closest_pos is None:
|
||||
z = None
|
||||
else:
|
||||
z = closest_pos[2]
|
||||
z = None if closest_pos is None else closest_pos[2]
|
||||
|
||||
return next_location, z
|
||||
|
||||
|
|
@ -363,10 +360,7 @@ class SmartSpiral(ScanPlanner):
|
|||
|
||||
# If focused locations exist, return the neighbour with the lowest z position
|
||||
closest_pos = self.select_nearby_focus_site(next_location)
|
||||
if closest_pos is None:
|
||||
z = None
|
||||
else:
|
||||
z = closest_pos[2]
|
||||
z = None if closest_pos is None else closest_pos[2]
|
||||
|
||||
return next_location, z
|
||||
|
||||
|
|
|
|||
|
|
@ -165,9 +165,7 @@ class PreviewStitcher(BaseStitcher):
|
|||
with self._popen_lock:
|
||||
if self._popen_obj is None:
|
||||
return False
|
||||
if self._popen_obj.poll() is None:
|
||||
return True
|
||||
return False
|
||||
return self._popen_obj.poll() is None
|
||||
|
||||
def wait(self, cancel: lt.deps.CancelHook) -> None:
|
||||
"""Wait for this preview stitch to return.
|
||||
|
|
|
|||
|
|
@ -334,9 +334,8 @@ class SmartScanThing(lt.Thing):
|
|||
"""Manage the stitching threads, starting them if needed and not already running."""
|
||||
# Assume 4 images means at least one offset in x and y, making the stitching
|
||||
# well constrained.
|
||||
if self._scan_data.image_count > 3:
|
||||
if not self._preview_stitcher.running:
|
||||
self._preview_stitcher.start()
|
||||
if self._scan_data.image_count > 3 and not self._preview_stitcher.running:
|
||||
self._preview_stitcher.start()
|
||||
|
||||
@_scan_running
|
||||
def _run_scan(self) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue