if
statements can be merged PTC-W0048281 raise ValueError("`returns` must be a pandas Series, "
282 "but a multi-column DataFrame was passed")
283
284 if benchmark is not None:285 if isinstance(returns, _pd.DataFrame) and len(returns.columns) > 1:
286 raise ValueError("`benchmark` must be a pandas Series, "
287 "but a multi-column DataFrame was passed")
Nested if
statements can be collapsed into a single if
statement by separating their condition using and
operator.
Merging collapsible if
statements increases the code's readability.
if condition1:
if condition2:
dosomething()
if condition1 and condition2:
dosomething()
DeepSource will not raise this issue when the nested if
statements have comments in between them, as it could be explaining why the nested if
is in place.