From 5b39bab7cb3f4c6edc1b1bbe1decd4e83f4df55d Mon Sep 17 00:00:00 2001 From: Oliver Switzer Date: Mon, 11 Aug 2025 08:55:09 -0400 Subject: [PATCH] style: additional linter improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix remaining line length issues in prompt_splitter_node.py and tests - Add missing docstring for INPUT_TYPES method - Fix import order to follow standard (stdlib, third-party, local) - Fix variable redefinition by using json_module alias - Add docstrings to test classes - Improve code readability and maintainability Linter score: 8.89/10 → 8.98/10 (+0.09) --- nodes/lora_visualizer_node.py | 9 ++++++--- nodes/prompt_splitter_node.py | 9 ++++++--- tests/test_lora_parsing.py | 2 ++ tests/test_prompt_splitter.py | 5 ++++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/nodes/lora_visualizer_node.py b/nodes/lora_visualizer_node.py index 9b1d6eb..9d7c774 100644 --- a/nodes/lora_visualizer_node.py +++ b/nodes/lora_visualizer_node.py @@ -5,8 +5,10 @@ Parses prompts for LoRA tags and displays metadata, thumbnails, and example imag import os import json -import folder_paths from typing import Dict, List, Tuple, Optional + +import folder_paths + from .lora_metadata_utils import parse_lora_tags @@ -33,6 +35,7 @@ class LoRAVisualizerNode: @classmethod def INPUT_TYPES(cls): + """Define the input schema for this ComfyUI node.""" return { "required": { "prompt_text": ( @@ -313,8 +316,8 @@ class LoRAVisualizerNode: } # Convert to readable string format - import json + import json as json_module - raw_info_output = json.dumps(raw_metadata, indent=2, ensure_ascii=False) + raw_info_output = json_module.dumps(raw_metadata, indent=2, ensure_ascii=False) return (raw_info_output, prompt_text) diff --git a/nodes/prompt_splitter_node.py b/nodes/prompt_splitter_node.py index 47b8acb..f4dd20b 100644 --- a/nodes/prompt_splitter_node.py +++ b/nodes/prompt_splitter_node.py @@ -139,7 +139,8 @@ Input Prompt: "woman dancing overwatch, ana gracefully she jumps up and down" "(video: twirls gracefully) ", "tooltip": ( "Combined prompt to be split into image and video prompts.\n" - "Supports: → image, → video\n" + "Supports: → image, " + " → video\n" "Verbatim: (image: text) → image, (video: text) → video\n" "AI splits remaining content into static visuals vs motion/actions." ), @@ -411,7 +412,8 @@ Input Prompt: "woman dancing overwatch, ana gracefully she jumps up and down" self._extract_verbatim_directives(prompt_text) ) log( - f"Prompt Splitter: Found {len(image_verbatim)} image and {len(video_verbatim)} video verbatim directives" + f"Prompt Splitter: Found {len(image_verbatim)} image and " + f"{len(video_verbatim)} video verbatim directives" ) self._send_progress_update(0.2, "Parsing LoRA tags and trigger words...") @@ -420,7 +422,8 @@ Input Prompt: "woman dancing overwatch, ana gracefully she jumps up and down" log("Prompt Splitter: Parsing LoRA tags...") standard_loras, wanloras = self.parse_lora_tags(prompt_text) log( - f"Prompt Splitter: Found {len(standard_loras)} standard LoRAs and {len(wanloras)} WanLoRAs" + f"Prompt Splitter: Found {len(standard_loras)} standard LoRAs and " + f"{len(wanloras)} WanLoRAs" ) # Extract and remove trigger words for all LoRAs (use prompt without wrappers) diff --git a/tests/test_lora_parsing.py b/tests/test_lora_parsing.py index b0e9e09..05d97c4 100644 --- a/tests/test_lora_parsing.py +++ b/tests/test_lora_parsing.py @@ -21,6 +21,7 @@ from nodes.lora_visualizer_node import LoRAVisualizerNode class TestLoRAVisualizerNode(unittest.TestCase): + """Test LoRA parsing functionality in the visualizer node.""" def setUp(self): """Set up test fixtures before each test method.""" @@ -236,6 +237,7 @@ class TestLoRAVisualizerNode(unittest.TestCase): class TestVisualizeLoras(unittest.TestCase): + """Test the visualize_loras method integration.""" def setUp(self): """Set up test fixtures before each test method.""" diff --git a/tests/test_prompt_splitter.py b/tests/test_prompt_splitter.py index 65cdc80..8da5707 100644 --- a/tests/test_prompt_splitter.py +++ b/tests/test_prompt_splitter.py @@ -267,7 +267,10 @@ class TestPromptSplitterNode(unittest.TestCase): def test_split_prompt_with_trigger_words(self): """split_prompt should handle trigger words correctly.""" - input_prompt = "beautiful woman dancing with motion-blur " + input_prompt = ( + "beautiful woman dancing with motion-blur " + "" + ) # Mock metadata for LoRAs mock_image_metadata = {"civitai": {"trainedWords": ["beautiful"]}}