Closed
Description
Steps to reproduce
Given a file a.py
:
"""Test pylint W0621"""
class CustomException(Exception):
"""Customized Exception"""
def func():
"""Override CustomException by except .. as .."""
try:
raise CustomException('Test')
except IOError as CustomException:
pass
Current behavior
Result of pylint a.py
:
************* Module test
test.py:8:14: E0601: Using variable 'CustomException' before assignment (used-before-assignment)
------------------------------------------------------------------
Your code has been rated at 1.67/10 (previous run: 1.67/10, +0.00)
Expected behavior
Expecting pylint reports W0621 redefined-outer-name
on line except IOError as CustomException
I tested overriding the outer name by with .. as ..
, and the W0621 reported without problems.
In my opinion, W0621 should also be reported when the outer name gets redefined by except .. as ..
.
pylint --version output
Result of pylint --version
output:
pylint 2.8.2
astroid 2.5.6
Python 3.9.2 (default, Apr 12 2021, 14:14:14)
[Clang 12.0.0 (clang-1200.0.32.29)]