From 395bfbd670a6bf3fa043f5e7b509b9df5b83a714 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 6 Oct 2021 21:38:34 +0200 Subject: Deprecate ``is_typing_guard`` and ``is_sys_guard`` (#1202) * Deprecate is_typing_guard and is_sys_guard References #1199 Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> --- astroid/nodes/node_classes.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'astroid') diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py index c54f82e2..d59db37c 100644 --- a/astroid/nodes/node_classes.py +++ b/astroid/nodes/node_classes.py @@ -39,6 +39,7 @@ import abc import itertools import sys import typing +import warnings from functools import lru_cache from typing import TYPE_CHECKING, Callable, Generator, Optional @@ -2870,6 +2871,10 @@ class If(mixins.MultiLineBlockMixin, mixins.BlockRangeMixIn, Statement): >>> node.is_sys_guard() True """ + warnings.warn( + "The 'is_sys_guard' function is deprecated and will be removed in astroid 3.0.0", + DeprecationWarning, + ) if isinstance(self.test, Compare): value = self.test.left if isinstance(value, Subscript): @@ -2891,6 +2896,10 @@ class If(mixins.MultiLineBlockMixin, mixins.BlockRangeMixIn, Statement): >>> node.is_typing_guard() True """ + warnings.warn( + "The 'is_typing_guard' function is deprecated and will be removed in astroid 3.0.0", + DeprecationWarning, + ) return isinstance( self.test, (Name, Attribute) ) and self.test.as_string().endswith("TYPE_CHECKING") -- cgit v1.2.1