diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2019-09-17 09:27:06 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-09-17 09:27:06 +0200 |
commit | a7f236528bb3758886b97285a56f3f9ce5b13a99 (patch) | |
tree | 14b6eb36ac771d26c1a06123d490b2e181185027 /tests/functional/u | |
parent | 2a5c1abe2ea2e5add666565b125529dcd33daccc (diff) | |
download | pylint-git-a7f236528bb3758886b97285a56f3f9ce5b13a99.tar.gz |
Handle variables defined only under a type checking clause
These kind of variables will cause a runtime error, since the variable
will not be defined, unless we use the `annotations` future.
Close #3081
Diffstat (limited to 'tests/functional/u')
-rw-r--r-- | tests/functional/u/undefined_variable.py | 11 | ||||
-rw-r--r-- | tests/functional/u/undefined_variable.txt | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/functional/u/undefined_variable.py b/tests/functional/u/undefined_variable.py index 59af47e19..619794573 100644 --- a/tests/functional/u/undefined_variable.py +++ b/tests/functional/u/undefined_variable.py @@ -245,3 +245,14 @@ def nonlocal_in_ifexp(): fig = plt.figure() fig.canvas.mpl_connect('button_press_event', onclick) plt.show(block=True) + + +# pylint: disable=wrong-import-position +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from datetime import datetime + + +def func_should_fail(_dt: datetime): # [used-before-assignment] + pass diff --git a/tests/functional/u/undefined_variable.txt b/tests/functional/u/undefined_variable.txt index bc935c12d..5f9ca9747 100644 --- a/tests/functional/u/undefined_variable.txt +++ b/tests/functional/u/undefined_variable.txt @@ -24,3 +24,4 @@ undefined-variable:161::Undefined variable 'unicode_2' undefined-variable:171::Undefined variable 'unicode_4' undefined-variable:226:LambdaClass4.<lambda>:Undefined variable 'LambdaClass4' undefined-variable:234:LambdaClass5.<lambda>:Undefined variable 'LambdaClass5' +used-before-assignment:257:func_should_fail:Using variable 'datetime' before assignment |