From 8cd5fbc92666b3045aa3b6f7912bce063284bad4 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 12 Sep 2025 16:28:53 -0400 Subject: [PATCH] lint Signed-off-by: Vladimir Mandic --- .ruff.toml | 1 + modules/face/instantid_model.py | 2 +- modules/processing_vae.py | 2 +- modules/sdnq/__init__.py | 4 ++-- modules/upscaler.py | 1 - scripts/consistory_ext.py | 2 +- scripts/instantir/ip_adapter/resampler.py | 2 +- scripts/layerdiffuse/layerdiffuse_model.py | 2 +- scripts/loopback.py | 2 +- scripts/outpainting_mk_2.py | 2 +- scripts/style_aligned/inversion.py | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index f5b4d3c2b..74b734878 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -85,6 +85,7 @@ ignore = [ "RUF013", # PEP 484 prohibits implicit `Optional` "RUF015", # Prefer `next(...)` over single element slice "RUF046", # Value being cast to `int` is already an integer + "RUF059", # Unpacked variables are not used "RUF051", # Prefer pop over del ] fixable = ["ALL"] diff --git a/modules/face/instantid_model.py b/modules/face/instantid_model.py index 9bccda014..8df9075d9 100644 --- a/modules/face/instantid_model.py +++ b/modules/face/instantid_model.py @@ -58,7 +58,7 @@ def FeedForward(dim, mult=4): def reshape_tensor(x, heads): - bs, length, width = x.shape + bs, length, _width = x.shape # (bs, length, width) --> (bs, length, n_heads, dim_per_head) x = x.view(bs, length, heads, -1) # (bs, length, n_heads, dim_per_head) --> (bs, n_heads, length, dim_per_head) diff --git a/modules/processing_vae.py b/modules/processing_vae.py index c97ffa12b..883686152 100644 --- a/modules/processing_vae.py +++ b/modules/processing_vae.py @@ -276,7 +276,7 @@ def vae_decode(latents, model, output_type='np', vae_type='Full', width=None, he shared.state.end(jobid) if tensors is not None and len(tensors) > 0: return vae_postprocess(tensors, model, output_type) - + jobid = shared.state.begin('VAE Decode') if latents.shape[0] == 0: shared.log.error(f'VAE nothing to decode: {latents.shape}') diff --git a/modules/sdnq/__init__.py b/modules/sdnq/__init__.py index 63297c6b8..8b95fab0c 100644 --- a/modules/sdnq/__init__.py +++ b/modules/sdnq/__init__.py @@ -541,10 +541,10 @@ class SDNQConfig(QuantizationConfigMixin): self.modules_dtype_dict = {} -import diffusers.quantizers.auto # noqa: E402,RUF100 +import diffusers.quantizers.auto # noqa: E402,RUF100 # pylint: disable=wrong-import-order diffusers.quantizers.auto.AUTO_QUANTIZER_MAPPING["sdnq"] = SDNQQuantizer diffusers.quantizers.auto.AUTO_QUANTIZATION_CONFIG_MAPPING["sdnq"] = SDNQConfig -import transformers.quantizers.auto # noqa: E402,RUF100 +import transformers.quantizers.auto # noqa: E402,RUF100 # pylint: disable=wrong-import-order transformers.quantizers.auto.AUTO_QUANTIZER_MAPPING["sdnq"] = SDNQQuantizer transformers.quantizers.auto.AUTO_QUANTIZATION_CONFIG_MAPPING["sdnq"] = SDNQConfig diff --git a/modules/upscaler.py b/modules/upscaler.py index d9ae47828..3494742e8 100644 --- a/modules/upscaler.py +++ b/modules/upscaler.py @@ -1,5 +1,4 @@ import os -import copy from abc import abstractmethod from PIL import Image from modules import modelloader, shared diff --git a/scripts/consistory_ext.py b/scripts/consistory_ext.py index 0042e348f..b91d74fa7 100644 --- a/scripts/consistory_ext.py +++ b/scripts/consistory_ext.py @@ -195,7 +195,7 @@ class Script(scripts_manager.Script): shared.log.warning(f'ConsiStory: class={shared.sd_model.__class__.__name__} model={shared.sd_model_type} required={supported_model_list}') return None - subject, concepts, prompts, dropout, sampler, steps, same, queries, sdsa, freeu, freeu_preset, alpha, injection = args # pylint: disable=unused-variable + subject, concepts, prompts, dropout, sampler, steps, same, queries, sdsa, freeu, _freeu_preset, alpha, injection = args # pylint: disable=unused-variable self.create_model() # create model if not already done concepts, anchors, prompts, alpha, steps, seed = self.set_args(p, *args) # set arguments diff --git a/scripts/instantir/ip_adapter/resampler.py b/scripts/instantir/ip_adapter/resampler.py index 72295f90b..540257db2 100644 --- a/scripts/instantir/ip_adapter/resampler.py +++ b/scripts/instantir/ip_adapter/resampler.py @@ -21,7 +21,7 @@ def FeedForward(dim, mult=4): def reshape_tensor(x, heads): - bs, length, width = x.shape + bs, length, _width = x.shape # (bs, length, width) --> (bs, length, n_heads, dim_per_head) x = x.view(bs, length, heads, -1) # (bs, length, n_heads, dim_per_head) --> (bs, n_heads, length, dim_per_head) diff --git a/scripts/layerdiffuse/layerdiffuse_model.py b/scripts/layerdiffuse/layerdiffuse_model.py index 6311a9d53..87de86672 100644 --- a/scripts/layerdiffuse/layerdiffuse_model.py +++ b/scripts/layerdiffuse/layerdiffuse_model.py @@ -270,7 +270,7 @@ class TransparentVAEDecoder(AutoencoderKL): alpha = y[..., :1] fg = y[..., 1:] - B, H, W, C = fg.shape + _B, H, W, _C = fg.shape cb = checkerboard(shape=(H // 64, W // 64)) cb = cv2.resize(cb, (W, H), interpolation=cv2.INTER_LANCZOS4) cb = (0.5 + (cb - 0.5) * 0.1)[None, ..., None] diff --git a/scripts/loopback.py b/scripts/loopback.py index a359dd83b..a22b153a2 100644 --- a/scripts/loopback.py +++ b/scripts/loopback.py @@ -56,7 +56,7 @@ class Script(scripts_manager.Script): change = (final_denoising_strength - initial_denoising_strength) * strength return initial_denoising_strength + change - for n in range(initial_batch_count): + for _n in range(initial_batch_count): p.init_images = initial_init_images p.denoising_strength = initial_denoising_strength last_image = None diff --git a/scripts/outpainting_mk_2.py b/scripts/outpainting_mk_2.py index 0d587b2ca..b9288fc22 100644 --- a/scripts/outpainting_mk_2.py +++ b/scripts/outpainting_mk_2.py @@ -206,7 +206,7 @@ class Script(scripts_manager.Script): p.n_iter = 1 state.job_count = batch_count * ((1 if left > 0 else 0) + (1 if right > 0 else 0) + (1 if up > 0 else 0) + (1 if down > 0 else 0)) all_processed_images = [] - for i in range(batch_count): + for _i in range(batch_count): imgs = [init_img] * batch_size if left > 0: imgs = expand(imgs, batch_size, left, is_left=True) diff --git a/scripts/style_aligned/inversion.py b/scripts/style_aligned/inversion.py index 8c91cc02a..1686dfe7f 100644 --- a/scripts/style_aligned/inversion.py +++ b/scripts/style_aligned/inversion.py @@ -49,7 +49,7 @@ def _get_text_embeddings(prompt: str, tokenizer, text_encoder, device): def _encode_text_sdxl(model: StableDiffusionXLPipeline, prompt: str) -> tuple[dict[str, T], T]: device = model._execution_device # pylint: disable=protected-access - prompt_embeds, pooled_prompt_embeds, = _get_text_embeddings(prompt, model.tokenizer, model.text_encoder, device) # pylint: disable=unused-variable + prompt_embeds, _pooled_prompt_embeds, = _get_text_embeddings(prompt, model.tokenizer, model.text_encoder, device) # pylint: disable=unused-variable prompt_embeds_2, pooled_prompt_embeds2, = _get_text_embeddings( prompt, model.tokenizer_2, model.text_encoder_2, device) prompt_embeds = torch.cat((prompt_embeds, prompt_embeds_2), dim=-1) text_encoder_projection_dim = model.text_encoder_2.config.projection_dim