diff options
author | Jacob Walls <jacobtylerwalls@gmail.com> | 2023-03-11 14:54:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-11 14:54:32 -0500 |
commit | 4c56ba82d7aac50b1ea34e929833c91418e1d117 (patch) | |
tree | 8b8d3594de027cbd970e24d9ff117f05f10ebb51 /tests/checkers | |
parent | 74e6efcec09dff861254289465a3f06c803dbc4f (diff) | |
download | pylint-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.py | 10 |
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) |