diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2019-11-13 09:09:57 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-11-13 09:09:57 +0100 |
commit | 02688062140cc7ffa9c4f1a1f04c13d6f198a400 (patch) | |
tree | 5da0eee5ea4a429c61c660c8df832e86cc3f6a27 /tests/functional | |
parent | c9cf63ebaa671a34b7d9947eebd1d0da904dbcb0 (diff) | |
download | pylint-git-02688062140cc7ffa9c4f1a1f04c13d6f198a400.tar.gz |
Do not exempt bare except from ``undefined-variable`` and similar checks
If a node was wrapped in a ``TryExcept``, ``pylint`` was taking a hint
from the except handler when deciding to emit or not a message.
We were treating bare except as a fully fledged ignore but only
the corresponding exceptions should be handled that way (e.g. ``NameError`` or ``ImportError``)
Close #3235
Diffstat (limited to 'tests/functional')
-rw-r--r-- | tests/functional/n/no_name_in_module.py | 2 | ||||
-rw-r--r-- | tests/functional/u/undefined_variable.py | 7 | ||||
-rw-r--r-- | tests/functional/u/undefined_variable.txt | 8 |
3 files changed, 6 insertions, 11 deletions
diff --git a/tests/functional/n/no_name_in_module.py b/tests/functional/n/no_name_in_module.py index 8b309fd0a..73ad2db93 100644 --- a/tests/functional/n/no_name_in_module.py +++ b/tests/functional/n/no_name_in_module.py @@ -52,7 +52,7 @@ except Exception: try: import collections.emit1 -except: +except ImportError: pass try: diff --git a/tests/functional/u/undefined_variable.py b/tests/functional/u/undefined_variable.py index 917368cfe..4323bfd3c 100644 --- a/tests/functional/u/undefined_variable.py +++ b/tests/functional/u/undefined_variable.py @@ -167,12 +167,7 @@ except Exception: pass try: - unicode_3 -except: - pass - -try: - unicode_4 # [undefined-variable] + unicode_3 # [undefined-variable] except ValueError: pass diff --git a/tests/functional/u/undefined_variable.txt b/tests/functional/u/undefined_variable.txt index 4a0e83aec..fa86ff5b6 100644 --- a/tests/functional/u/undefined_variable.txt +++ b/tests/functional/u/undefined_variable.txt @@ -21,7 +21,7 @@ used-before-assignment:145:KeywordArgument.test1:Using variable 'enabled' before undefined-variable:148:KeywordArgument.test2:Undefined variable 'disabled' undefined-variable:153:KeywordArgument.<lambda>:Undefined variable 'arg' undefined-variable:165::Undefined variable 'unicode_2' -undefined-variable:175::Undefined variable 'unicode_4' -undefined-variable:230:LambdaClass4.<lambda>:Undefined variable 'LambdaClass4' -undefined-variable:238:LambdaClass5.<lambda>:Undefined variable 'LambdaClass5' -used-before-assignment:259:func_should_fail:Using variable 'datetime' before assignment +undefined-variable:170::Undefined variable 'unicode_3' +undefined-variable:225:LambdaClass4.<lambda>:Undefined variable 'LambdaClass4' +undefined-variable:233:LambdaClass5.<lambda>:Undefined variable 'LambdaClass5' +used-before-assignment:254:func_should_fail:Using variable 'datetime' before assignment |