in pydeequ/suggestions.py [0:0]
def __s2p_filter(code: str):
"""
Scala -> Python translator for the constraint suggestions code
A method that returns the python translation of the scala constraint suggestion
:param str code: a scala constraint suggestion
:return code that is translated to look more like python code
"""
if " _ " in code:
code = code.replace(" _ ", " lambda x: x ")
if "Some(" in code:
# Usually at the end as 'where' or 'hint' strings as optional
code = code.replace("Some(", "")[:-1]
if "Array(" in code:
# TODO: what if multiple?
# TODO: Probz redo with regex
start = code.index("Array(") + len("Array(")
for idx in range(start, len(code)):
if code[idx] == ")":
code = code[:idx] + "]" + code[idx + 1 :]
code = code.replace("Array(", "[")
break
if "Seq(" in code:
# TODO: what if multiple?
# TODO: Probz redo with regex
start = code.index("Seq(") + len("Seq(")
for idx in range(start, len(code)):
if code[idx] == ")":
code = code[:idx] + "]" + code[idx + 1 :]
code = code.replace("Seq(", "[")
break
return code