From 139e331d80215c98a93d78974d43552c646cf238 Mon Sep 17 00:00:00 2001 From: CalamitousFelicitousness Date: Mon, 2 Feb 2026 22:54:47 +0000 Subject: [PATCH] style(caption): fix lint warnings across caption module - Rename shadowing import in waifudiffusion batch to avoid F823/E0606 - Fix import order in cli/api-caption.py (stdlib before third-party) - Rename local variable shadowing function name in cli/api-caption.py - Remove unnecessary global statement in devices.bypass_sdpa_hijacks --- cli/api-caption.py | 16 ++++++++-------- modules/caption/waifudiffusion.py | 4 ++-- modules/devices.py | 2 -- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cli/api-caption.py b/cli/api-caption.py index e76bd4943..69c87302e 100755 --- a/cli/api-caption.py +++ b/cli/api-caption.py @@ -8,8 +8,8 @@ import base64 import sys import os import asyncio -import filetype from types import SimpleNamespace +import filetype from PIL import Image from util import log, Map import sdapi @@ -53,15 +53,15 @@ async def caption(f): # run clip json.model = 'clip' res = await sdapi.post('/sdapi/v1/caption', json) - caption = "" + result = "" style = "" if 'caption' in res: - caption = res.caption - log.info({ 'caption result': caption }) - if ', by' in caption: - style = caption.split(', by')[1].strip() + result = res.caption + log.info({ 'caption result': result }) + if ', by' in result: + style = result.split(', by')[1].strip() log.info({ 'caption style': style }) - for word in caption.split(' '): + for word in result.split(' '): if word not in exclude: stats['captions'][word] = stats['captions'][word] + 1 if word in stats['captions'] else 1 else: @@ -81,7 +81,7 @@ async def caption(f): log.info({'caption tags': res.tags}) else: log.error({'caption tagger error': res}) - return caption, keywords, style + return result, keywords, style async def main(): diff --git a/modules/caption/waifudiffusion.py b/modules/caption/waifudiffusion.py index e0089f233..4189fc989 100644 --- a/modules/caption/waifudiffusion.py +++ b/modules/caption/waifudiffusion.py @@ -506,8 +506,8 @@ def batch( tags_str = tagger.predict(image, **kwargs) if save_output: - from modules.caption import tagger - tagger.save_tags_to_file(img_path, tags_str, save_append) + from modules.caption import tagger as tagger_module + tagger_module.save_tags_to_file(img_path, tags_str, save_append) results.append(f'{img_path.name}: {tags_str[:100]}...' if len(tags_str) > 100 else f'{img_path.name}: {tags_str}') diff --git a/modules/devices.py b/modules/devices.py index 0b403f225..1c3cde685 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -666,8 +666,6 @@ def bypass_sdpa_hijacks(): Context manager to temporarily restore the original SDPA during code execution. Use when a model is incompatible with SageAttention or other SDPA hijacks. """ - global sdpa_original # pylint: disable=global-statement - if sdpa_original is None: # No hijacks applied, nothing to bypass yield