Sample code, test.py:
"""Reproducer."""
def fun():
"""Description."""
try:
pass
except Exception as exc:
raise exc
try:
pass
except OSError as exc:
if exc.errno == 42:
pass
then run:
pylint test.py
exc is used first with Exception type, and then reused later on as OSError (which has errno). pylint is confused and claims exc has no errno because it still thinks it's of type Exception:
test.py:12:11: E1101: Instance of 'Exception' has no 'errno' member (no-member)
pylint correctly identifies the type of the variable the second time it's used in an except block.
pylint 2.3.1
astroid 2.2.4
Python 3.7.2 (default, Feb 12 2019, 08:15:36)
[Clang 10.0.0 (clang-1000.11.45.5)]
Bisect note: works with pylint 2.2.3, breaks with at least 2.3.0.
This relates to dberzano/alidock#105.
Hey @dberzano Thanks for creating the issue! This is already fixed in astroid's master and I just backported those changes to astroid 2.2 I'll do a 2.2.5 release in a bit so this issue should go away once that's done.
Thanks! This explains why the issue was still there yesterday even with pip install pylint astroid --pre -U.
Most helpful comment
Hey @dberzano Thanks for creating the issue! This is already fixed in astroid's master and I just backported those changes to astroid 2.2 I'll do a 2.2.5 release in a bit so this issue should go away once that's done.