Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issue #18 by adding whitespace stripping functionality to query/response parsing. The implementation strips whitespace from input strings before validation, allowing for more flexible input handling.
- Added whitespace stripping to the
parse_inp_or_outpfunction usings.strip() - Reorganized test cases by splitting valid and invalid cases into separate test functions
- Added test coverage for input strings with surrounding whitespace
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/gimkit/schemas.py | Added s.strip() to remove whitespace before parsing |
| tests/test_parsing.py | Reorganized tests and added whitespace handling test case |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Comment on lines
+33
to
+34
| m_input = '\n<|M_INPUT|>This is an <|MASKED id="m_0"|><|/MASKED|> text.<|/M_INPUT|>\n\n \t' | ||
| m_output = ' \n<|M_OUTPUT|>\n<|MASKED id="m_0"|>example<|/MASKED|><|/M_OUTPUT|>\n' |
There was a problem hiding this comment.
[nitpick] The whitespace test case uses mixed whitespace characters (spaces, newlines, tabs) in a way that's hard to read and verify. Consider using more explicit whitespace or adding comments to clarify what specific whitespace scenarios are being tested.
Suggested change
| m_input = '\n<|M_INPUT|>This is an <|MASKED id="m_0"|><|/MASKED|> text.<|/M_INPUT|>\n\n \t' | |
| m_output = ' \n<|M_OUTPUT|>\n<|MASKED id="m_0"|>example<|/MASKED|><|/M_OUTPUT|>\n' | |
| # m_input: leading newline, trailing two newlines, space, and tab | |
| m_input = ( | |
| "\n" # leading newline | |
| "<|M_INPUT|>This is an <|MASKED id=\"m_0\"|><|/MASKED|> text.<|/M_INPUT|>" | |
| "\n\n \t" # two newlines, space, tab at end | |
| ) | |
| # m_output: leading space and newline, newline after prefix, trailing newline | |
| m_output = ( | |
| " \n" # leading space and newline | |
| "<|M_OUTPUT|>\n" | |
| "<|MASKED id=\"m_0\"|>example<|/MASKED|><|/M_OUTPUT|>" | |
| "\n" # trailing newline | |
| ) |
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.
Fixes #18