Handle None input in sanitize function#119
Open
MehdiLotfian wants to merge 1 commit intobigcode-project:mainfrom
Open
Handle None input in sanitize function#119MehdiLotfian wants to merge 1 commit intobigcode-project:mainfrom
MehdiLotfian wants to merge 1 commit intobigcode-project:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a guard in the tree-sitter–based sanitizer to tolerate None inputs, avoiding runtime errors during code post-processing of LLM outputs.
Changes:
- Return an empty string early when
sanitize()receivesNone. - Keep existing sanitize/extract fallback behavior unchanged for non-
Noneinputs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| @@ -180,6 +180,8 @@ def extract_target_code_or_empty(code: str, entrypoint: Optional[str] = None) -> | |||
|
|
|||
|
|
|||
| def sanitize(code: str, entrypoint: Optional[str] = None) -> str: | |||
Comment on lines
182
to
+183
| def sanitize(code: str, entrypoint: Optional[str] = None) -> str: | ||
| if code is None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLMs fails to generate answers for some tasks. the added if block prevent error in running the generation code in these cases.