diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 91a017e4..d8932645 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,12 +6,12 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black exclude: ^hordelib/nodes/.*\..*$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.11 + rev: v0.2.1 hooks: - id: ruff - repo: https://github.com/pre-commit/mirrors-mypy @@ -19,4 +19,4 @@ repos: hooks: - id: mypy exclude: ^examples/.*$ # FIXME - additional_dependencies: [pydantic, strenum, types-colorama, types-docutils, types-Pillow, types-psutil, types-Pygments, types-pywin32, types-PyYAML, types-regex, types-requests, types-setuptools, types-tabulate, types-tqdm, types-urllib3] + additional_dependencies: [pydantic, strenum, types-colorama, types-docutils, types-Pillow, types-psutil, types-Pygments, types-pywin32, types-PyYAML, types-regex, types-requests, types-setuptools, types-tabulate, types-tqdm, types-urllib3, horde_sdk] diff --git a/hordelib/model_manager/base.py b/hordelib/model_manager/base.py index 8ba81486..1ef6022a 100644 --- a/hordelib/model_manager/base.py +++ b/hordelib/model_manager/base.py @@ -498,17 +498,20 @@ def download_file( response.raise_for_status() # Write the content to file in chunks - with open(partial_pathname, "ab") as f, tqdm( - # all optional kwargs - unit="B", - initial=partial_size, - unit_scale=True, - unit_divisor=1024, - miniters=1, - desc=filename, - total=remote_file_size + partial_size, - # disable=UserSettings.download_progress_callback is not None, - ) as pbar: + with ( + open(partial_pathname, "ab") as f, + tqdm( + # all optional kwargs + unit="B", + initial=partial_size, + unit_scale=True, + unit_divisor=1024, + miniters=1, + desc=filename, + total=remote_file_size + partial_size, + # disable=UserSettings.download_progress_callback is not None, + ) as pbar, + ): downloaded = partial_size for chunk in response.iter_content(chunk_size=1024 * 1024 * 16): response.raise_for_status() diff --git a/hordelib/model_manager/hyper.py b/hordelib/model_manager/hyper.py index 3c8bfa5e..93bb7c7e 100644 --- a/hordelib/model_manager/hyper.py +++ b/hordelib/model_manager/hyper.py @@ -1,4 +1,5 @@ """Home for the controller class ModelManager, and related meta information.""" + import os import threading from collections.abc import Callable, Iterable @@ -180,9 +181,9 @@ def init_model_managers( self.active_model_managers.append( resolve_manager_to_load_type( multiprocessing_lock=multiprocessing_lock, - civitai_api_token=os.environ["CIVIT_API_TOKEN"] - if "CIVIT_API_TOKEN" in os.environ.keys() - else None, + civitai_api_token=( + os.environ["CIVIT_API_TOKEN"] if "CIVIT_API_TOKEN" in os.environ.keys() else None + ), ), )