summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-03-11 21:52:06 +0100
committerGitHub <noreply@github.com>2023-03-11 21:52:06 +0100
commit575319bb87de73114203c5a49edd3ae18aace8c7 (patch)
tree7c5575bd368782df1f60e568c1b13053a1963475 /tests
parent8c3652a6a4c97d0ed0e92484d4ce15e669bd69cf (diff)
downloadpylint-git-575319bb87de73114203c5a49edd3ae18aace8c7.tar.gz
Fix a crash when `TYPE_CHECKING` is used without importing it (#8435) (#8436)
(cherry picked from commit 4c56ba82d7aac50b1ea34e929833c91418e1d117) Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Diffstat (limited to 'tests')
-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 b2cbcb590..a0dfe299b 100644
--- a/tests/checkers/unittest_utils.py
+++ b/tests/checkers/unittest_utils.py
@@ -447,6 +447,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)