style: additional linter improvements
- 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)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -139,7 +139,8 @@ Input Prompt: "woman dancing overwatch, ana gracefully she jumps up and down"
|
||||
"(video: twirls gracefully) <wanlora:motion:1.0>",
|
||||
"tooltip": (
|
||||
"Combined prompt to be split into image and video prompts.\n"
|
||||
"Supports: <lora:name:strength> → image, <wanlora:name:strength> → video\n"
|
||||
"Supports: <lora:name:strength> → image, "
|
||||
"<wanlora:name:strength> → 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)
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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 <lora:style:0.8> dancing with motion-blur <wanlora:motion:1.0>"
|
||||
input_prompt = (
|
||||
"beautiful woman <lora:style:0.8> dancing with motion-blur "
|
||||
"<wanlora:motion:1.0>"
|
||||
)
|
||||
|
||||
# Mock metadata for LoRAs
|
||||
mock_image_metadata = {"civitai": {"trainedWords": ["beautiful"]}}
|
||||
|
||||
Reference in New Issue
Block a user