Skip to content
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

Fix code newline character issue introduced by astor.to_source #345

Merged
merged 4 commits into from
Jul 8, 2023

Conversation

redpin-pankaj
Copy link
Contributor

@redpin-pankaj
Copy link
Contributor Author

redpin-pankaj commented Jul 7, 2023

I preferred to avoid using ast.unparse() because of the warnings given in the documentation.

Also turns out that overriding the pretty_source() function when calling astor.to_source() using a simple lambda fuction which bypasses the split_lines() seems to do the trick.

Also repurposing _clean_code() method to return last line is not necessary because ast seems to remove within-expression newlines automatically, so there is no risk even if LLM is returning within-expression newlines in the code.

@gventuri
Copy link
Collaborator

gventuri commented Jul 8, 2023

@psaini-qontigo great job, well done! Merging!

@gventuri gventuri merged commit daf7336 into Sinaptik-AI:main Jul 8, 2023
3 checks passed
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

Successfully merging this pull request may close these issues.

astor.to_source() seems to add a newline in the code when unparsing the AST tree
2 participants