A few small fixes for the untranslated datasets #163
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.
Hi, while working on #162, I was digging into some translation issues and ran across a few things in the untranslated datasets that I thought should probably be updated.
I've included two commits. The first makes a few mionr changes to doctests, one of which is just a change in whitespacing, while the other fixes an issue with the doctest that causes a translation failure. The second commit includes a few typehint changes, mostly for cases where
Any
was used, but a more descriptive type could have been used instead.While I think most of the changes are fine (totally unbiased, of course), I suspect the two most objectional changes will be:
Increasing the use of
Tuple[T, ...]
This indicates that a Tuple could have any length, with all elements being of type T. These changes generally replace instances of
Any
with eitherTuple[Any, ...]
orTuple[some_type, ...]
However there are some translators, like the one for typescript, that support
Any
but do not support the ellipsis notation in Tuples, hence why maybe this change could be objectional.MBPP_595
I'm convinced it is impossible to pass this problem as it is currently written without cheating. It's typed to just return
Any
. The docstring doesn't include any guidance about the expected output format. Most logically, this would be eitherint | None
, orint
and-1
is used to represent that it's impossible. I don't believe anyone would guess that the expected output format isint | 'Not Possible'
. So, while I would be very surprised if any of the translators support translating this typehint (Union[int, Literal['Not Possible']]
), without this change I'm not sure how any model is expected to generate a correct solution for this problemFor completeness here are the changes in translation ratio that I observed:
Full summary of changes
Any
toTuple[Any, ...]
Any
toTuple[List[Any], List[Any]]
to match the docstring and testsAny
toUnion[int, bool]
.Union[int, Literal[False]]
to be more accurate, but existing translators won't handle thisList[Any]
toList[Union[str, int]]
, as the input was restricted to only contain strings and integers.List[Tuple[Any, ...]]
, and leave the return type asList[Any]
Any
toTuple[Any, ...]
Any
toTuple[int, ...]
Any
toUnion[int, Literal['Not Possible']
List[Any]
toList[str]
List[Any]
toList[int]
Any
toTuple[Any, ...]
List[Any]
toList[int]
There are also a number of other things that I noticed but didn't change, mostly because I wasn't confident about the solution, but that maybe should still be looked into. Let me know if you'd like me to raise an issue to capture these.
Optional[Literal[True]]
, though the existing translators wouldn't support this.