diff options
| author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-10-06 21:38:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-06 21:38:34 +0200 |
| commit | 395bfbd670a6bf3fa043f5e7b509b9df5b83a714 (patch) | |
| tree | c3246a295183264aac48b1e53c1e58304308949f | |
| parent | a92487baedf9e85a587ac6fc0b5f99c7cec04f46 (diff) | |
| download | astroid-git-395bfbd670a6bf3fa043f5e7b509b9df5b83a714.tar.gz | |
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>
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | astroid/nodes/node_classes.py | 9 |
2 files changed, 14 insertions, 0 deletions
@@ -40,6 +40,11 @@ Release date: TBA Closes PyCQA/pylint#5059 +* The ``is_typing_guard`` and ``is_sys_guard`` functions are deprecated and will + be removed in 3.0.0. They are complex meta-inference functions that are better + suited for pylint. Import them from ``pylint.checkers.utils`` instead + (requires pylint ``2.12``). + What's New in astroid 2.8.0? ============================ 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") |
