File tree 3 files changed +9
-8
lines changed
tests/functional/u/undefined
3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -738,14 +738,14 @@ def _exhaustively_define_name_raise_or_return(
738
738
if any (node .nodes_of_class (nodes .Break )):
739
739
return True
740
740
741
- # If there is no else, then there is no collectively exhaustive set of paths
742
- if not node .orelse :
743
- return False
744
-
745
741
# Is there an assignment in this node itself, e.g. in named expression?
746
742
if NamesConsumer ._defines_name_raises_or_returns (name , node ):
747
743
return True
748
744
745
+ # If there is no else, then there is no collectively exhaustive set of paths
746
+ if not node .orelse :
747
+ return False
748
+
749
749
return NamesConsumer ._branch_handles_name (
750
750
name , node .body
751
751
) and NamesConsumer ._branch_handles_name (name , node .orelse )
Original file line number Diff line number Diff line change @@ -182,6 +182,7 @@ def expression_in_ternary_operator_inside_container_wrong_position():
182
182
z = z + 1
183
183
184
184
185
- if (never_defined := False ):
186
- pass
187
- print (never_defined ) # [used-before-assignment]
185
+ if (defined := False ):
186
+ NEVER_DEFINED = 1
187
+ print (defined )
188
+ print (NEVER_DEFINED ) # [used-before-assignment]
Original file line number Diff line number Diff line change @@ -8,4 +8,4 @@ used-before-assignment:140:10:140:16:type_annotation_used_improperly_after_compr
8
8
used-before-assignment:147:10:147:16:type_annotation_used_improperly_after_comprehension_2:Using variable 'my_int' before assignment:HIGH
9
9
used-before-assignment:177:12:177:16:expression_in_ternary_operator_inside_container_wrong_position:Using variable 'val3' before assignment:HIGH
10
10
used-before-assignment:181:9:181:10::Using variable 'z' before assignment:HIGH
11
- used-before-assignment:187 :6:187 :19::Using variable 'never_defined ' before assignment:CONTROL_FLOW
11
+ used-before-assignment:188 :6:188 :19::Using variable 'NEVER_DEFINED ' before assignment:CONTROL_FLOW
You can’t perform that action at this time.
0 commit comments