From bc64cde6f9ca02d68627a54b46ff37ab6e0fe0b5 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 14 Nov 2023 07:57:07 +1100 Subject: [PATCH] chore: ruff lint --- invokeai/app/api/routers/model_records.py | 2 +- invokeai/backend/model_manager/hash.py | 4 ++-- .../model_records/test_model_records_sql.py | 20 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/invokeai/app/api/routers/model_records.py b/invokeai/app/api/routers/model_records.py index 298b30735a..51a4481acb 100644 --- a/invokeai/app/api/routers/model_records.py +++ b/invokeai/app/api/routers/model_records.py @@ -42,7 +42,7 @@ async def list_model_records( """Get a list of models.""" record_store = ApiDependencies.invoker.services.model_records if base_models and len(base_models) > 0: - models_raw = list() + models_raw = [] for base_model in base_models: models_raw.extend( [x.model_dump() for x in record_store.search_by_attr(base_model=base_model, model_type=model_type)] diff --git a/invokeai/backend/model_manager/hash.py b/invokeai/backend/model_manager/hash.py index f26f3f4394..fb563a8cda 100644 --- a/invokeai/backend/model_manager/hash.py +++ b/invokeai/backend/model_manager/hash.py @@ -49,7 +49,7 @@ class FastModelHash(object): def _hash_dir(cls, model_location: Union[str, Path]) -> str: components: Dict[str, str] = {} - for root, dirs, files in os.walk(model_location): + for root, _dirs, files in os.walk(model_location): for file in files: # only tally tensor files because diffusers config files change slightly # depending on how the model was downloaded/converted. @@ -61,6 +61,6 @@ class FastModelHash(object): # hash all the model hashes together, using alphabetic file order md5 = hashlib.md5() - for path, fast_hash in sorted(components.items()): + for _path, fast_hash in sorted(components.items()): md5.update(fast_hash.encode("utf-8")) return md5.hexdigest() diff --git a/tests/app/services/model_records/test_model_records_sql.py b/tests/app/services/model_records/test_model_records_sql.py index 52a7c40dfd..02a55c89ac 100644 --- a/tests/app/services/model_records/test_model_records_sql.py +++ b/tests/app/services/model_records/test_model_records_sql.py @@ -52,16 +52,16 @@ def test_type(store: ModelRecordServiceBase): def test_add(store: ModelRecordServiceBase): - raw = dict( - path="/tmp/foo.ckpt", - name="model1", - base=BaseModelType("sd-1"), - type="main", - config="/tmp/foo.yaml", - variant="normal", - format="checkpoint", - original_hash="111222333444", - ) + raw = { + "path": "/tmp/foo.ckpt", + "name": "model1", + "base": BaseModelType("sd-1"), + "type": "main", + "config": "/tmp/foo.yaml", + "variant": "normal", + "format": "checkpoint", + "original_hash": "111222333444", + } store.add_model("key1", raw) config1 = store.get_model("key1") assert config1 is not None