File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed
tests/functional/ext/code_style Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 1+ Fix crash for ``consider-using-assignment-expr`` when a variable annotation without assignment
2+ is used as the ``if`` test expression.
3+
4+ Closes #10707
Original file line number Diff line number Diff line change @@ -314,7 +314,7 @@ def _check_prev_sibling_to_if_stmt(
314314 case nodes .Assign (
315315 targets = [nodes .AssignName (name = target_name )]
316316 ) | nodes .AnnAssign (target = nodes .AssignName (name = target_name )):
317- return target_name == name # type: ignore[no-any-return]
317+ return target_name == name and prev_sibling . value is not None # type: ignore[no-any-return]
318318 return False
319319
320320 @staticmethod
Original file line number Diff line number Diff line change @@ -157,3 +157,8 @@ class A:
157157A .var = 2
158158if A .var :
159159 ...
160+
161+
162+ i : int
163+ if i : # pylint: disable=used-before-assignment
164+ pass
You can’t perform that action at this time.
0 commit comments