@@ -118,8 +118,7 @@ def _is_a_return_statement(node: nodes.Call) -> bool:
118
118
119
119
120
120
def _is_part_of_with_items (node : nodes .Call ) -> bool :
121
- """
122
- Checks if one of the node's parents is a ``nodes.With`` node and that the node itself is located
121
+ """Checks if one of the node's parents is a ``nodes.With`` node and that the node itself is located
123
122
somewhere under its ``items``.
124
123
"""
125
124
frame = node .frame ()
@@ -135,7 +134,8 @@ def _is_part_of_with_items(node: nodes.Call) -> bool:
135
134
136
135
def _will_be_released_automatically (node : nodes .Call ) -> bool :
137
136
"""Checks if a call that could be used in a ``with`` statement is used in an alternative
138
- construct which would ensure that its __exit__ method is called."""
137
+ construct which would ensure that its __exit__ method is called.
138
+ """
139
139
callables_taking_care_of_exit = frozenset (
140
140
(
141
141
"contextlib._BaseExitStack.enter_context" ,
@@ -152,7 +152,8 @@ def _will_be_released_automatically(node: nodes.Call) -> bool:
152
152
153
153
class ConsiderUsingWithStack (NamedTuple ):
154
154
"""Stack for objects that may potentially trigger a R1732 message
155
- if they are not used in a ``with`` block later on."""
155
+ if they are not used in a ``with`` block later on.
156
+ """
156
157
157
158
module_scope : Dict [str , nodes .NodeNG ] = {}
158
159
class_scope : Dict [str , nodes .NodeNG ] = {}
@@ -1278,7 +1279,8 @@ def _apply_boolean_simplification_rules(operator, values):
1278
1279
reverse for AND
1279
1280
1280
1281
2) False values in OR expressions are only relevant if all values are
1281
- false, and the reverse for AND"""
1282
+ false, and the reverse for AND
1283
+ """
1282
1284
simplified_values = []
1283
1285
1284
1286
for subnode in values :
@@ -1299,7 +1301,8 @@ def _simplify_boolean_operation(self, bool_op):
1299
1301
"""Attempts to simplify a boolean operation
1300
1302
1301
1303
Recursively applies simplification on the operator terms,
1302
- and keeps track of whether reductions have been made."""
1304
+ and keeps track of whether reductions have been made.
1305
+ """
1303
1306
children = list (bool_op .get_children ())
1304
1307
intermediate = [
1305
1308
self ._simplify_boolean_operation (child )
@@ -1320,7 +1323,8 @@ def _check_simplifiable_condition(self, node):
1320
1323
"""Check if a boolean condition can be simplified.
1321
1324
1322
1325
Variables will not be simplified, even in the value can be inferred,
1323
- and expressions like '3 + 4' will remain expanded."""
1326
+ and expressions like '3 + 4' will remain expanded.
1327
+ """
1324
1328
if not utils .is_test_condition (node ):
1325
1329
return
1326
1330
@@ -1506,8 +1510,7 @@ def _check_use_list_or_dict_literal(self, node: nodes.Call) -> None:
1506
1510
self .add_message ("use-dict-literal" , node = node )
1507
1511
1508
1512
def _check_consider_using_join (self , aug_assign ):
1509
- """
1510
- We start with the augmented assignment and work our way upwards.
1513
+ """We start with the augmented assignment and work our way upwards.
1511
1514
Names of variables for nodes if match successful:
1512
1515
result = '' # assign
1513
1516
for number in ['1', '2', '3'] # for_loop
@@ -1630,8 +1633,7 @@ def _check_unnecessary_comprehension(self, node: nodes.Comprehension) -> None:
1630
1633
1631
1634
@staticmethod
1632
1635
def _is_and_or_ternary (node ):
1633
- """
1634
- Returns true if node is 'condition and true_value or false_value' form.
1636
+ """Returns true if node is 'condition and true_value or false_value' form.
1635
1637
1636
1638
All of: condition, true_value and false_value should not be a complex boolean expression
1637
1639
"""
@@ -1793,9 +1795,7 @@ def _is_node_return_ended(self, node: nodes.NodeNG) -> bool:
1793
1795
1794
1796
@staticmethod
1795
1797
def _has_return_in_siblings (node : nodes .NodeNG ) -> bool :
1796
- """
1797
- Returns True if there is at least one return in the node's siblings
1798
- """
1798
+ """Returns True if there is at least one return in the node's siblings"""
1799
1799
next_sibling = node .next_sibling ()
1800
1800
while next_sibling :
1801
1801
if isinstance (next_sibling , nodes .Return ):
0 commit comments