diff options
author | Zen Lee <53538590+zenlyj@users.noreply.github.com> | 2023-04-16 02:01:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-15 20:01:37 +0200 |
commit | 6028f202c4b637f9edc54cef815586a54fd65958 (patch) | |
tree | 054b07291b3edb59a244956dc28c14e687642544 /tests | |
parent | 2db55f6a48962aa7ff4cc3b0ee4b37177f605bdc (diff) | |
download | pylint-git-6028f202c4b637f9edc54cef815586a54fd65958.tar.gz |
Fix `used-before-assignment` TYPE_CHECKING false negatives (#8431)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functional/u/used/used_before_assignment_scoping.py | 18 | ||||
-rw-r--r-- | tests/functional/u/used/used_before_assignment_scoping.txt | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/functional/u/used/used_before_assignment_scoping.py b/tests/functional/u/used/used_before_assignment_scoping.py new file mode 100644 index 000000000..0d88210bd --- /dev/null +++ b/tests/functional/u/used/used_before_assignment_scoping.py @@ -0,0 +1,18 @@ +# pylint: disable=missing-function-docstring, missing-module-docstring + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from datetime import datetime + + +def func_two(): + second = datetime.now() # [used-before-assignment] + return second + + +def func(): + first: datetime + first = datetime.now() # [used-before-assignment] + second = datetime.now() + return first, second diff --git a/tests/functional/u/used/used_before_assignment_scoping.txt b/tests/functional/u/used/used_before_assignment_scoping.txt new file mode 100644 index 000000000..32b6d3e1b --- /dev/null +++ b/tests/functional/u/used/used_before_assignment_scoping.txt @@ -0,0 +1,2 @@ +used-before-assignment:10:13:10:21:func_two:Using variable 'datetime' before assignment:CONTROL_FLOW +used-before-assignment:16:12:16:20:func:Using variable 'datetime' before assignment:CONTROL_FLOW |