From 92b2e8186a7e51930b4dd66d1ccf4585b74b8379 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sun, 10 Mar 2024 12:02:19 +1100 Subject: [PATCH] tidy(mm): simplify types for ModelSearch - Use `set` instead of `Set` - Methods accept only `Path`s --- invokeai/backend/model_manager/search.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/invokeai/backend/model_manager/search.py b/invokeai/backend/model_manager/search.py index b6e51e94d8..8d110b1257 100644 --- a/invokeai/backend/model_manager/search.py +++ b/invokeai/backend/model_manager/search.py @@ -23,7 +23,7 @@ Example usage: import os from dataclasses import dataclass from pathlib import Path -from typing import Callable, Optional, Set, Union +from typing import Callable, Optional from invokeai.backend.util.logging import InvokeAILogger @@ -57,7 +57,7 @@ class ModelSearch: self, on_search_started: Optional[Callable[[Path], None]] = None, on_model_found: Optional[Callable[[Path], bool]] = None, - on_search_completed: Optional[Callable[[Set[Path]], None]] = None, + on_search_completed: Optional[Callable[[set[Path]], None]] = None, ) -> None: """Create a new ModelSearch object. @@ -89,7 +89,7 @@ class ModelSearch: if self.on_search_completed is not None: self.on_search_completed(self.models_found) - def search(self, directory: Union[Path, str]) -> Set[Path]: + def search(self, directory: Path) -> set[Path]: self._directory = Path(directory) self._directory = self._directory.resolve() self.stats = SearchStats() # zero out @@ -98,7 +98,7 @@ class ModelSearch: self.search_completed() return self.models_found - def _walk_directory(self, path: Union[Path, str], max_depth: int = 20) -> None: + def _walk_directory(self, path: Path, max_depth: int = 20) -> None: """Recursively walk the directory tree, looking for models.""" absolute_path = Path(path) if (