I have some if statements like:
def is_valid(self):
if (self.expires is None or datetime.now() < self.expires)
and (self.remains is None or self.remains > 0):
return True
return False
When I type this expressions my Vim automatically moves and to new line with this same indent as if line . I try more indent combinations, but validating always says thats invalid syntax. How to build long if’s?
Add an additional level of brackets around the whole condition. This will allow you to insert line breaks as you wish.
Regarding the actual number of spaces to use, the Python Style Guide doesn’t mandate anything but gives some ideas: