WASasquatch / was-node-suite-comfyui

An extensive node suite for ComfyUI with over 210 new nodes
MIT License
1.19k stars 178 forks source link

Update WAS_Node_Suite.py #77

Closed shadownetdev1 closed 1 year ago

shadownetdev1 commented 1 year ago

Changed TEXT_TYPE to "STRING" to allow better custom node compatibility. I have done quite a bit of testing and everything seems to be working just fine. image

WASasquatch commented 1 year ago

if TEXT_TYPE == "STRING": with no else case means if TEXT_TYPE is set to anything other then 'STRING' there will be no inputs.

You shouldn't need a if statement for the return case.

"text": (TEXT_TYPE, {"forceInput": (True if TEXT_TYPE == 'STRING' else False)}),
shadownetdev1 commented 1 year ago

They are if/else blocks without an explicit else block:

        if TEXT_TYPE == "STRING":
            return {
                "required": {
                    "text": (TEXT_TYPE, {"forceInput": True}),
                }
            }
            # we returned so code execution stops here
        # if block wasn't executed, so it didn't return, so code below gets executed returning
        return {
            "required": {
                "text": (TEXT_TYPE, ),

While it will take quite a bit of work, your solution does make the code cleaner. If you wish me to convert all of my code to your solution before merging I would be willing to do so.

shadownetdev1 commented 1 year ago

I commonly use this method to keep my characters per line count down.

Here is some example code to help show this:

car = True
make = "Honda"
model = "CR-V"
year = "2018"

if car is True:
    if make == "Honda":
        if model == "CR-V":
            if year == "2018":
                return f"{make}, {model}, {year}"
            else:
                return None
        else:
            return None
    else:
        return None
else:
    return None
# 13 lines, longest line: 48 characters

if car is False:
    return None
if make != "Honda":
    return None
if model != "CR-V":
    return None
if year != "2018":
    return None
return f"{make}, {model}, {year}"
# 9 lines, longest line: 33 character

I try to keep my lines below 80 characters to allow me to view multiple files side by side with ease

WASasquatch commented 1 year ago

I'd rather more condensed file then added lines. Shorthand as much as you can. It's a large file and linear parsing adds time.

And sorry github naturally show the edit comapared to original, but falls short of continuation on edit so looked like single if statements.

shadownetdev1 commented 1 year ago

Converted all the if statements to shorthand

WASasquatch commented 1 year ago

Thanks for the update.