@@ -1061,7 +1061,7 @@ def _check_stop_iteration_inside_generator(self, node: nodes.Raise) -> None:
10611061 if not node .exc :
10621062 return
10631063 exc = utils .safe_infer (node .exc )
1064- if not exc or not isinstance (exc , (bases .Instance , nodes .ClassDef )):
1064+ if not isinstance (exc , (bases .Instance , nodes .ClassDef )):
10651065 return
10661066 if self ._check_exception_inherit_from_stopiteration (exc ):
10671067 self .add_message ("stop-iteration-return" , node = node , confidence = INFERENCE )
@@ -1712,7 +1712,7 @@ def _check_use_list_literal(self, node: nodes.Call) -> None:
17121712
17131713 def _check_use_dict_literal (self , node : nodes .Call ) -> None :
17141714 """Check if dict is created by using the literal {}."""
1715- if not isinstance (node .func , astroid .Name ) or node .func .name != "dict" :
1715+ if not ( isinstance (node .func , astroid .Name ) and node .func .name == "dict" ) :
17161716 return
17171717 inferred = utils .safe_infer (node .func )
17181718 if (
@@ -1753,7 +1753,7 @@ def _name_to_concatenate(self, node: nodes.NodeNG) -> str | None:
17531753 values = [
17541754 value for value in node .values if isinstance (value , nodes .FormattedValue )
17551755 ]
1756- if len (values ) != 1 or not isinstance (values [0 ].value , nodes .Name ):
1756+ if not ( len (values ) == 1 and isinstance (values [0 ].value , nodes .Name ) ):
17571757 return None
17581758 # If there are more values in joined string than formatted values,
17591759 # they are probably separators.
@@ -1772,7 +1772,7 @@ def _check_consider_using_join(self, aug_assign: nodes.AugAssign) -> None:
17721772 result += number # aug_assign
17731773 """
17741774 for_loop = aug_assign .parent
1775- if not isinstance (for_loop , nodes .For ) or len (for_loop .body ) > 1 :
1775+ if not ( isinstance (for_loop , nodes .For ) and len (for_loop .body ) == 1 ) :
17761776 return
17771777 assign = for_loop .previous_sibling ()
17781778 if not isinstance (assign , nodes .Assign ):
@@ -1810,11 +1810,10 @@ def visit_comprehension(self, node: nodes.Comprehension) -> None:
18101810 self ._check_unnecessary_list_index_lookup (node )
18111811
18121812 def _check_unnecessary_comprehension (self , node : nodes .Comprehension ) -> None :
1813- if (
1814- isinstance (node .parent , nodes .GeneratorExp )
1815- or len (node .ifs ) != 0
1816- or len (node .parent .generators ) != 1
1817- or node .is_async
1813+ if isinstance (node .parent , nodes .GeneratorExp ) or not (
1814+ len (node .ifs ) == 0
1815+ and len (node .parent .generators ) == 1
1816+ and node .is_async is False
18181817 ):
18191818 return
18201819
0 commit comments