Closed shadownetdev1 closed 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)}),
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.
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
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.
Converted all the if statements to shorthand
Thanks for the update.
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.