if
statements can be merged PTC-W0048151 elif hasattr(types, "CoroutineType") and isinstance(obj, types.CoroutineType):
152 if attr in UNSAFE_COROUTINE_ATTRIBUTES:
153 return True
154 elif hasattr(types, "AsyncGeneratorType") and isinstance(155 obj, types.AsyncGeneratorType
156 ):
157 if attr in UNSAFE_ASYNC_GENERATOR_ATTRIBUTES:
220 todo = deque([self])
221 while todo:
222 node = todo.popleft()
223 if "lineno" in node.attributes: 224 if node.lineno is None or override:
225 node.lineno = lineno
226 todo.extend(node.iter_child_nodes())
1588 # -- Expression Visitors
1589
1590 def visit_Name(self, node: nodes.Name, frame: Frame) -> None:
1591 if node.ctx == "store" and (1592 frame.toplevel or frame.loop_frame or frame.block_frame
1593 ):
1594 if self._assign_stack:
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.