Skip to content

Commit 395bfbd

Browse files
Deprecate is_typing_guard and is_sys_guard (#1202)
* Deprecate is_typing_guard and is_sys_guard References #1199 Co-authored-by: Marc Mueller <[email protected]>
1 parent a92487b commit 395bfbd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ Release date: TBA
4040

4141
Closes PyCQA/pylint#5059
4242

43+
* The ``is_typing_guard`` and ``is_sys_guard`` functions are deprecated and will
44+
be removed in 3.0.0. They are complex meta-inference functions that are better
45+
suited for pylint. Import them from ``pylint.checkers.utils`` instead
46+
(requires pylint ``2.12``).
47+
4348

4449
What's New in astroid 2.8.0?
4550
============================

astroid/nodes/node_classes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import itertools
4040
import sys
4141
import typing
42+
import warnings
4243
from functools import lru_cache
4344
from typing import TYPE_CHECKING, Callable, Generator, Optional
4445

@@ -2870,6 +2871,10 @@ def is_sys_guard(self) -> bool:
28702871
>>> node.is_sys_guard()
28712872
True
28722873
"""
2874+
warnings.warn(
2875+
"The 'is_sys_guard' function is deprecated and will be removed in astroid 3.0.0",
2876+
DeprecationWarning,
2877+
)
28732878
if isinstance(self.test, Compare):
28742879
value = self.test.left
28752880
if isinstance(value, Subscript):
@@ -2891,6 +2896,10 @@ def is_typing_guard(self) -> bool:
28912896
>>> node.is_typing_guard()
28922897
True
28932898
"""
2899+
warnings.warn(
2900+
"The 'is_typing_guard' function is deprecated and will be removed in astroid 3.0.0",
2901+
DeprecationWarning,
2902+
)
28942903
return isinstance(
28952904
self.test, (Name, Attribute)
28962905
) and self.test.as_string().endswith("TYPE_CHECKING")

0 commit comments

Comments
 (0)