fix: Linter AI errors
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
from .enhanced_uuid_generator import *
|
||||
from .enhanced_uuid_generator import (
|
||||
NODE_CLASS_MAPPINGS,
|
||||
NODE_DISPLAY_NAME_MAPPINGS,
|
||||
)
|
||||
|
||||
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
|
||||
|
||||
@@ -16,12 +16,24 @@ class EnhancedUUIDGeneratorNode:
|
||||
try:
|
||||
return uuid.UUID(custom_namespace_uuid_str)
|
||||
except ValueError:
|
||||
raise ValueError("Invalid custom namespace UUID string.")
|
||||
raise ValueError(
|
||||
"Invalid custom namespace UUID string."
|
||||
)
|
||||
else:
|
||||
raise ValueError("Invalid namespace type.")
|
||||
raise ValueError(
|
||||
"Invalid namespace type."
|
||||
)
|
||||
|
||||
def generate_uuid_enhanced(self, uuid_type, namespace_type="DNS", custom_namespace_uuid="",
|
||||
name_string="example.com", prefix="", suffix="", trigger=0):
|
||||
def generate_uuid_enhanced(
|
||||
self,
|
||||
uuid_type,
|
||||
namespace_type="DNS",
|
||||
custom_namespace_uuid="",
|
||||
name_string="example.com",
|
||||
prefix="",
|
||||
suffix="",
|
||||
trigger=0,
|
||||
):
|
||||
if trigger == 0:
|
||||
return None
|
||||
|
||||
@@ -36,7 +48,9 @@ class EnhancedUUIDGeneratorNode:
|
||||
elif uuid_type == "UUID5":
|
||||
generated_uuid = uuid.uuid5(namespace, name_string)
|
||||
else:
|
||||
raise ValueError("Invalid UUID type.")
|
||||
raise ValueError(
|
||||
"Invalid UUID type."
|
||||
)
|
||||
|
||||
return f"{prefix}{generated_uuid}{suffix}"
|
||||
|
||||
@@ -46,4 +60,6 @@ NODE_CLASS_MAPPINGS = {
|
||||
"EnhancedUUIDGeneratorNode": EnhancedUUIDGeneratorNode
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_M
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"EnhancedUUIDGeneratorNode": "Enhanced UUID Generator"
|
||||
}
|
||||
|
||||
@@ -19,32 +19,44 @@ class UUIDGeneratorNode:
|
||||
# The 'trigger' here doesn't affect the UUID (uuid4 is random)
|
||||
# but allows the user to change a value to force
|
||||
# re-execution of the node if needed.
|
||||
"trigger": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
"prefix": ("STRING", {"default": "", "multiline": False}),
|
||||
"suffix": ("STRING", {"default": "", "multiline": False}),
|
||||
"trigger": (
|
||||
"INT",
|
||||
{"default": 0, "min": 0, "max": 0xffffffffffffffff}
|
||||
),
|
||||
"prefix": (
|
||||
"STRING",
|
||||
{"default": "", "multiline": False}
|
||||
),
|
||||
"suffix": (
|
||||
"STRING",
|
||||
{"default": "", "multiline": False}
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
# Define the output types the node produces
|
||||
RETURN_TYPES = ("STRING",)
|
||||
# Optional: names for the outputs (if there's more than one, it's more useful)
|
||||
RETURN_NAMES = ("uuid_string",)
|
||||
RETURN_NAMES = (
|
||||
"uuid_string",
|
||||
)
|
||||
|
||||
# Define the main function that will be executed
|
||||
FUNCTION = "generate_uuid"
|
||||
|
||||
# Define the category where the node will appear in ComfyUI's menu
|
||||
CATEGORY = "utils/text" # You can change "utils/text" to your preference
|
||||
CATEGORY = (
|
||||
"utils/text"
|
||||
) # You can change "utils/text" to your preference
|
||||
|
||||
# Indicates if this node is a final output node (like SaveImage)
|
||||
# In this case, it is not.
|
||||
OUTPUT_NODE = False
|
||||
|
||||
def __init__(self): # E302: expected 2 blank lines, found 1
|
||||
self.value = None # E261: at least two spaces before inline comment
|
||||
self.another_value = 0 # E261: at least two spaces before inline comment
|
||||
self.some_flag = True # E261: at least two spaces before inline comment
|
||||
self.last_value = False # E261: at least two spaces before inline comment
|
||||
def __init__(self):
|
||||
self.value = None
|
||||
self.another_value = 0
|
||||
self.some_flag = True
|
||||
self.last_value = False
|
||||
|
||||
def reset(self):
|
||||
pass
|
||||
@@ -54,15 +66,18 @@ class UUIDGeneratorNode:
|
||||
|
||||
def generate_uuid(self, trigger=0, prefix="", suffix=""):
|
||||
"""
|
||||
Generates a v4 UUID and returns it as a string, optionally with a prefix and suffix.
|
||||
The 'trigger' parameter is not used for UUID generation itself,
|
||||
but changing it can force ComfyUI to re-run this node.
|
||||
Generates a v4 UUID and returns it as a string, optionally with a
|
||||
prefix and suffix. The 'trigger' parameter is not used for UUID
|
||||
generation itself, but changing it can force ComfyUI to re-run
|
||||
this node.
|
||||
"""
|
||||
# Generate a random v4 UUID
|
||||
generated_uuid = str(uuid.uuid4())
|
||||
|
||||
# Concatenate with prefix and suffix if provided
|
||||
result_string = f"{prefix}{generated_uuid}{suffix}"
|
||||
result_string = (
|
||||
f"{prefix}{generated_uuid}{suffix}"
|
||||
)
|
||||
|
||||
# ComfyUI nodes must return a tuple of results
|
||||
return (result_string,)
|
||||
@@ -70,8 +85,9 @@ class UUIDGeneratorNode:
|
||||
|
||||
# --- Mappings for ComfyUI to recognize the node ---
|
||||
# This dictionary maps an internal name (key) to the node class (value).
|
||||
# "UUIDGeneratorNode" is the name used in saved workflows (JSON)
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"UUIDGeneratorNode": UUIDGeneratorNode # "UUIDGeneratorNode" is the name used in saved workflows (JSON)
|
||||
"UUIDGeneratorNode": UUIDGeneratorNode
|
||||
}
|
||||
|
||||
# This dictionary maps the internal name to a human-readable name for the UI.
|
||||
@@ -81,4 +97,6 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
}
|
||||
|
||||
# Message for the console when the script is loaded (optional)
|
||||
print("--- Custom Node: UUID Generator loaded ---")
|
||||
print(
|
||||
"--- Custom Node: UUID Generator loaded ---"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user