summaryrefslogtreecommitdiff
path: root/tests/checkers
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2023-03-11 14:54:32 -0500
committerGitHub <noreply@github.com>2023-03-11 14:54:32 -0500
commit4c56ba82d7aac50b1ea34e929833c91418e1d117 (patch)
tree8b8d3594de027cbd970e24d9ff117f05f10ebb51 /tests/checkers
parent74e6efcec09dff861254289465a3f06c803dbc4f (diff)
downloadpylint-git-4c56ba82d7aac50b1ea34e929833c91418e1d117.tar.gz
Fix a crash when `TYPE_CHECKING` is used without importing it (#8435)
Diffstat (limited to 'tests/checkers')
-rw-r--r--tests/checkers/unittest_utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/checkers/unittest_utils.py b/tests/checkers/unittest_utils.py
index 231fed555..97234ccb1 100644
--- a/tests/checkers/unittest_utils.py
+++ b/tests/checkers/unittest_utils.py
@@ -446,6 +446,16 @@ def test_if_typing_guard() -> None:
assert utils.is_typing_guard(code[3]) is False
+def test_in_type_checking_block() -> None:
+ code = astroid.extract_node(
+ """
+ if TYPE_CHECKING: # don't import this!
+ import math #@
+ """
+ )
+ assert utils.in_type_checking_block(code) is False
+
+
def test_is_empty_literal() -> None:
list_node = astroid.extract_node("a = []")
assert utils.is_base_container(list_node.value)