Skip to content

workaround for "black.parsing.InvalidInput: Cannot parse" errors (requires basic Python skills) #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mbylstra opened this issue Apr 4, 2025 · 1 comment

Comments

@mbylstra
Copy link

mbylstra commented Apr 4, 2025

This error occurs because some plugins cause syntactically incorrect output, which trips up the Black formatter. However there is a workaround I've found:

From your ComfyUi directory, edit the file ./custom_nodes/comfyui-to-python-extension/comfyui_to_python.py
Just before line 413 that has final_code = black.format_str(final_code, mode=black.Mode()), add the line
FileHandler.write_code_to_file("unformatted_comfyui_to_python_output.py", final_code), which will the save the file before it is formatted.

Restart comfy and try exporting.

You should see a file unformatted_comfyui_to_python_output.py in the main directory.

Then you need to try to fix the file by hand. I use vscode with the pylance plugin (as part of the standard pythong plugin set that vscode should prompt you to install). It was very obvious to see where the issue was:

Image
For some reason there is a random Update in the middle. I just deleted that word and now the file works. (I have no idea why the Update was added - I haven't spent any time debugging that part - this was a quickfix).

The error was comfing from "Join String Multi" by KJNodes. I'm not sure if it will be this easy for other errors from other plugins, but it's worth a try!

@bernadinel
Copy link

bernadinel commented May 5, 2025

thank you
I got the same exact error:

"Update" was in the middle of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants