modernize
modernize copied to clipboard
Invalid syntax for if expression
I ran python-modernize on a legacy code base and it turned
result = filter(lambda item: True if item.get_license_number_minor() == self.get_license_number_minor() else False, license_list)
into
result = [item for item in license_list if True if item.get_license_number_minor() == self.get_license_number_minor() else False]
which the Python interpreter won't execute:
SyntaxError: invalid syntax
So, there are missing brackets around the if expression.
P.S.: Yes, the original code is strange, but it worked. Meanwhile i simplified the code and then python-modernize worked.