pycodestyle
pycodestyle copied to clipboard
Consistent use of "return None" in functions
Could you add this rule to pep8? I just updated the official PEP 8 to include this (I'm surprised it wasn't already there):
- Be consistent in return statements. Either all return statements in a function should return an expression, or none of them should. If any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function (if reachable).
Yes:
def foo(x):
if x >= 0:
return math.sqrt(x)
else:
return None
def bar(x):
if x < 0:
return None
return math.sqrt(x)
No:
def foo(x):
if x >= 0:
return math.sqrt(x)
def bar(x):
if x < 0:
return
return math.sqrt(x)
https://mail.python.org/pipermail/python-dev/2015-April/139054.html
So for anyone who might have the same problem as me.
You need to add anchors to custom nodes yourself, as they don't get automatically created on default nodes when you pass in connections.