diff options
author | Marc Mueller <30130371+cdce8p@users.noreply.github.com> | 2023-04-25 19:10:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 17:10:48 +0000 |
commit | 08ed4136d83ba88d1e605e4afad71a5420396eec (patch) | |
tree | 5e0094640d1514537e80def524b9f1bd4694aae5 /astroid | |
parent | 6865b2b04a22ccee4a34016520e667d5e517740d (diff) | |
download | astroid-git-08ed4136d83ba88d1e605e4afad71a5420396eec.tar.gz |
Remove deprecated `is_sys_guard` + `is_typing_guard` (#2153)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'astroid')
-rw-r--r-- | astroid/nodes/node_classes.py | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py index 9df654c5..2c28c7bc 100644 --- a/astroid/nodes/node_classes.py +++ b/astroid/nodes/node_classes.py @@ -9,7 +9,6 @@ from __future__ import annotations import abc import itertools import typing -import warnings from collections.abc import Generator, Iterable, Iterator, Mapping from functools import cached_property, lru_cache from typing import ( @@ -2483,59 +2482,6 @@ class If(_base_nodes.MultiLineWithElseBlockNode, _base_nodes.Statement): yield from self.test._get_yield_nodes_skip_lambdas() yield from super()._get_yield_nodes_skip_lambdas() - def is_sys_guard(self) -> bool: - """Return True if IF stmt is a sys.version_info guard. - - >>> import astroid - >>> node = astroid.extract_node(''' - import sys - if sys.version_info > (3, 8): - from typing import Literal - else: - from typing_extensions import Literal - ''') - >>> node.is_sys_guard() - True - """ - warnings.warn( - "The 'is_sys_guard' function is deprecated and will be removed in astroid 3.0.0 " - "It has been moved to pylint and can be imported from 'pylint.checkers.utils' " - "starting with pylint 2.12", - DeprecationWarning, - stacklevel=2, - ) - if isinstance(self.test, Compare): - value = self.test.left - if isinstance(value, Subscript): - value = value.value - if isinstance(value, Attribute) and value.as_string() == "sys.version_info": - return True - - return False - - def is_typing_guard(self) -> bool: - """Return True if IF stmt is a typing guard. - - >>> import astroid - >>> node = astroid.extract_node(''' - from typing import TYPE_CHECKING - if TYPE_CHECKING: - from xyz import a - ''') - >>> node.is_typing_guard() - True - """ - warnings.warn( - "The 'is_typing_guard' function is deprecated and will be removed in astroid 3.0.0 " - "It has been moved to pylint and can be imported from 'pylint.checkers.utils' " - "starting with pylint 2.12", - DeprecationWarning, - stacklevel=2, - ) - return isinstance( - self.test, (Name, Attribute) - ) and self.test.as_string().endswith("TYPE_CHECKING") - class IfExp(NodeNG): """Class representing an :class:`ast.IfExp` node. |