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

Handle empty text in Literal Eval #819

Merged
merged 3 commits into from
May 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/unitxt/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,6 @@ def process_value(self, text: Any) -> Any:

class LiteralEval(FieldOperator):
def process_value(self, text: Any) -> Any:
if not text:
Copy link
Member

@elronbandel elronbandel May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this more explicit? (if text is None or text == "":) Maybe it should raise error in that case?
Also any chance you can raise ValueError with detailed message in case that not isinstance(text, str)
And thanks againg for the contributions @antonpibm !

return text
return ast.literal_eval(text.strip())
Loading