Skip to content

Commit cf0cbaf

Browse files
chore: ruff (more)
1 parent ac6fc6e commit cf0cbaf

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

invokeai/app/invocations/segment_anything.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ def _filter_masks(
185185
# Find the largest mask.
186186
return [max(masks, key=lambda x: float(x.sum()))]
187187
elif self.mask_filter == "highest_box_score":
188-
assert (
189-
bounding_boxes is not None
190-
), "Bounding boxes must be provided to use the 'highest_box_score' mask filter."
188+
assert bounding_boxes is not None, (
189+
"Bounding boxes must be provided to use the 'highest_box_score' mask filter."
190+
)
191191
assert len(masks) == len(bounding_boxes)
192192
# Find the index of the bounding box with the highest score.
193193
# Note that we fallback to -1.0 if the score is None. This is mainly to satisfy the type checker. In most

invokeai/app/services/config/config_default.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,9 @@ def load_and_migrate_config(config_path: Path) -> InvokeAIAppConfig:
483483
try:
484484
# Meta is not included in the model fields, so we need to validate it separately
485485
config = InvokeAIAppConfig.model_validate(loaded_config_dict)
486-
assert (
487-
config.schema_version == CONFIG_SCHEMA_VERSION
488-
), f"Invalid schema version, expected {CONFIG_SCHEMA_VERSION}: {config.schema_version}"
486+
assert config.schema_version == CONFIG_SCHEMA_VERSION, (
487+
f"Invalid schema version, expected {CONFIG_SCHEMA_VERSION}: {config.schema_version}"
488+
)
489489
return config
490490
except Exception as e:
491491
raise RuntimeError(f"Failed to load config file {config_path}: {e}") from e

invokeai/app/services/workflow_records/workflow_records_sqlite.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ def _sync_default_workflows(self) -> None:
204204
bytes_ = path.read_bytes()
205205
workflow_from_file = WorkflowValidator.validate_json(bytes_)
206206

207-
assert workflow_from_file.id.startswith(
208-
"default_"
209-
), f'Invalid default workflow ID (must start with "default_"): {workflow_from_file.id}'
207+
assert workflow_from_file.id.startswith("default_"), (
208+
f'Invalid default workflow ID (must start with "default_"): {workflow_from_file.id}'
209+
)
210210

211-
assert (
212-
workflow_from_file.meta.category is WorkflowCategory.Default
213-
), f"Invalid default workflow category: {workflow_from_file.meta.category}"
211+
assert workflow_from_file.meta.category is WorkflowCategory.Default, (
212+
f"Invalid default workflow category: {workflow_from_file.meta.category}"
213+
)
214214

215215
workflows_from_file.append(workflow_from_file)
216216

invokeai/backend/model_manager/merge.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,19 @@ def merge_diffusion_models_and_save(
115115
base_models: Set[BaseModelType] = set()
116116
variant = None if self._installer.app_config.precision == "float32" else "fp16"
117117

118-
assert (
119-
len(model_keys) <= 2 or interp == MergeInterpolationMethod.AddDifference
120-
), "When merging three models, only the 'add_difference' merge method is supported"
118+
assert len(model_keys) <= 2 or interp == MergeInterpolationMethod.AddDifference, (
119+
"When merging three models, only the 'add_difference' merge method is supported"
120+
)
121121

122122
for key in model_keys:
123123
info = store.get_model(key)
124124
model_names.append(info.name)
125-
assert isinstance(
126-
info, MainDiffusersConfig
127-
), f"{info.name} ({info.key}) is not a diffusers model. It must be optimized before merging"
128-
assert info.variant == ModelVariantType(
129-
"normal"
130-
), f"{info.name} ({info.key}) is a {info.variant} model, which cannot currently be merged"
125+
assert isinstance(info, MainDiffusersConfig), (
126+
f"{info.name} ({info.key}) is not a diffusers model. It must be optimized before merging"
127+
)
128+
assert info.variant == ModelVariantType("normal"), (
129+
f"{info.name} ({info.key}) is a {info.variant} model, which cannot currently be merged"
130+
)
131131

132132
# tally base models used
133133
base_models.add(info.base)

tests/app/services/download/test_download_queue.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,12 @@ def event_handler(job: DownloadJob | MultiFileDownloadJob, excp: Optional[Except
212212
assert job.bytes > 0, "expected download bytes to be positive"
213213
assert job.bytes == job.total_bytes, "expected download bytes to equal total bytes"
214214
assert job.download_path == tmp_path / "sdxl-turbo"
215-
assert Path(
216-
tmp_path, "sdxl-turbo/model_index.json"
217-
).exists(), f"expected {tmp_path}/sdxl-turbo/model_inded.json to exist"
218-
assert Path(
219-
tmp_path, "sdxl-turbo/text_encoder/config.json"
220-
).exists(), f"expected {tmp_path}/sdxl-turbo/text_encoder/config.json to exist"
215+
assert Path(tmp_path, "sdxl-turbo/model_index.json").exists(), (
216+
f"expected {tmp_path}/sdxl-turbo/model_inded.json to exist"
217+
)
218+
assert Path(tmp_path, "sdxl-turbo/text_encoder/config.json").exists(), (
219+
f"expected {tmp_path}/sdxl-turbo/text_encoder/config.json to exist"
220+
)
221221

222222
assert events == {DownloadJobStatus.RUNNING, DownloadJobStatus.COMPLETED}
223223
queue.stop()

0 commit comments

Comments
 (0)