~When you're dealing with a property or method that returns boolean values, there is absolutely no need to compare it with True
or False
. It's a bad practice, even.
So, to solve both your PEP8 problem, and your filtering one, just omit the comparison, since Channel.is_default
will already yield True
or False
individually:
Channel.query.filter(Channel.is_default).all()
And if that filter doesn't give you any results, it's because not all
within your Channel
have is_default
set to True
. This filter is as straightforward as they come.
Edit: my answer was misinformed, the filter
function in sqlalchemy is a very particular case of conditionality in Python. See this question and its most prominent answers, which also answer OP's question as of now.