File tree 4 files changed +25
-0
lines changed
4 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -237,6 +237,12 @@ Release date: 2021-11-25
237
237
238
238
Closes #5342
239
239
240
+ * Fixed a false positive (affecting unreleased development) for
241
+ ``used-before-assignment`` involving homonyms between filtered comprehensions
242
+ and assignments in except blocks.
243
+
244
+ Closes #5586
245
+
240
246
* Specified that the ``ignore-paths`` option considers "\" to represent a
241
247
windows directory delimiter instead of a regular expression escape
242
248
character.
Original file line number Diff line number Diff line change @@ -139,6 +139,12 @@ Other Changes
139
139
140
140
Closes #5360, #3877
141
141
142
+ * Fixed a false positive (affecting unreleased development) for
143
+ ``used-before-assignment `` involving homonyms between filtered comprehensions
144
+ and assignments in except blocks.
145
+
146
+ Closes #5586
147
+
142
148
* Fixed crash on list comprehensions that used ``type `` as inner variable name.
143
149
144
150
Closes #5461
Original file line number Diff line number Diff line change @@ -1316,6 +1316,10 @@ def _check_consumer(
1316
1316
if utils .is_func_decorator (current_consumer .node ) or not (
1317
1317
current_consumer .scope_type == "comprehension"
1318
1318
and self ._has_homonym_in_upper_function_scope (node , consumer_level )
1319
+ and not (
1320
+ isinstance (node .parent .parent , nodes .Comprehension )
1321
+ and node .parent in node .parent .parent .ifs
1322
+ )
1319
1323
):
1320
1324
self ._check_late_binding_closure (node )
1321
1325
self ._loopvar_name (node )
Original file line number Diff line number Diff line change
1
+ """Homonym between filtered comprehension and assignment in except block."""
2
+
3
+ def func ():
4
+ """https://github.com/PyCQA/pylint/issues/5586"""
5
+ try :
6
+ print (value for value in range (1 / 0 ) if isinstance (value , int ))
7
+ except ZeroDivisionError :
8
+ value = 1
9
+ print (value )
You can’t perform that action at this time.
0 commit comments