@@ -1061,7 +1061,7 @@ def _check_stop_iteration_inside_generator(self, node: nodes.Raise) -> None:
1061
1061
if not node .exc :
1062
1062
return
1063
1063
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 )):
1065
1065
return
1066
1066
if self ._check_exception_inherit_from_stopiteration (exc ):
1067
1067
self .add_message ("stop-iteration-return" , node = node , confidence = INFERENCE )
@@ -1712,7 +1712,7 @@ def _check_use_list_literal(self, node: nodes.Call) -> None:
1712
1712
1713
1713
def _check_use_dict_literal (self , node : nodes .Call ) -> None :
1714
1714
"""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" ) :
1716
1716
return
1717
1717
inferred = utils .safe_infer (node .func )
1718
1718
if (
@@ -1753,7 +1753,7 @@ def _name_to_concatenate(self, node: nodes.NodeNG) -> str | None:
1753
1753
values = [
1754
1754
value for value in node .values if isinstance (value , nodes .FormattedValue )
1755
1755
]
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 ) ):
1757
1757
return None
1758
1758
# If there are more values in joined string than formatted values,
1759
1759
# they are probably separators.
@@ -1772,7 +1772,7 @@ def _check_consider_using_join(self, aug_assign: nodes.AugAssign) -> None:
1772
1772
result += number # aug_assign
1773
1773
"""
1774
1774
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 ) :
1776
1776
return
1777
1777
assign = for_loop .previous_sibling ()
1778
1778
if not isinstance (assign , nodes .Assign ):
@@ -1810,11 +1810,10 @@ def visit_comprehension(self, node: nodes.Comprehension) -> None:
1810
1810
self ._check_unnecessary_list_index_lookup (node )
1811
1811
1812
1812
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
1818
1817
):
1819
1818
return
1820
1819
0 commit comments