You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the report. For NameError this is expected, as pylint takes a hint from the exception handler in figuring out if the variable is expected to be undefined or not. For instance this is useful when wanting to check particular features of the language, like the presence of a builtin (in Python 2 vs Python 3 scenario for example).
But I think we should still emit it for bare except, and only allow NameError to swallow undefined variables.
Steps to reproduce
When an undefined variable is in a try-clause, pylint does not report it as undefined, depending on which type of exception we're catching.
It fails to detect the undefined variable if the exception is bare or
NameError
:It correctly detects the undefined variable if the exception is
Exception
or some other derived exception that is notNameError
:Current behavior
No error is raised (for bare exception and
NameError
)Expected behavior
E0602: Undefined variable 'bla' (undefined-variable)
pylint --version output
pylint 2.4.3
astroid 2.3.3
Python 3.7.3 (default, Oct 7 2019, 12:56:13)
[GCC 8.3.0]
The text was updated successfully, but these errors were encountered: